These are the CSS and Tailwind styles used by components libraries of Magma Design System to use the palette generated by @maggioli-design-system/design-tokens
.
Install the component via npm
by running the following command:
npm i @maggioli-design-system/styles
This package works also with yarn:
yarn add @maggioli-design-system/styles
The first part to be included are the design tokens, like color palette and typography, that are used by the components.
If you use tailwind or web components, you need to import rgb format of colors:
import '@maggioli-design-system/styles/dist/css/colors-rgb-tones.css';
import '@maggioli-design-system/styles/dist/css/colors-rgb-status.css';
import '@maggioli-design-system/styles/dist/css/colors-rgb-label.css';
import '@maggioli-design-system/styles/dist/css/colors-rgb-brand.css';
You need to import colors because web components and our tailwind config works with our palette, which are custom properties in rgb format (rr, gg, bb).
If for some reason you need to use colors outside tailwind:
.selector {
color: rgb(var(--tone-neutral-01));
}
If you need just the hex format of colors, you can import them like this:
import '@maggioli-design-system/styles/dist/css/colors-hex-tones.css';
import '@maggioli-design-system/styles/dist/css/colors-hex-status.css';
import '@maggioli-design-system/styles/dist/css/colors-hex-label.css';
import '@maggioli-design-system/styles/dist/css/colors-hex-brand.css';
Then you can use them like this:
.selector {
color: var(--tone-neutral-01);
}
our color palette already supports dark mode, either according to your computer settings, or with manual support:
Just add the dark-mode
class to the html
tag:
<html class="dark-mode">
Just add the system-mode
class to the html
tag:
<html class="system-mode">
There are other practices to handle dark mode, check how tailwind handle dark mode, or how is handled by next-themes.
You can use styles with tailwindcss config, palette colors and the rest of it's Design Tokens. There are various ways to use it, check out tailwindcss documentation.
To extend the default tailwind config:
module.exports = {
content: [
'./src/**/*.{ts,tsx}',
],
important: false,
presets: [
require('@maggioli-design-system/styles'),
],
}
Use @fontsource
fonts, which are up to date with Google fonts, styles used in Magma Design System are:
Importing fonts in TypeScript:
```ts
import '@fontsource/karla/400.css'
import '@fontsource/karla/700.css'
import '@fontsource/merriweather/400.css'
import '@fontsource/merriweather/700.css'
import '@fontsource/roboto-mono/400.css'
import '@fontsource/roboto/500.css'
import '@fontsource/roboto/700.css'
import '@fontsource/roboto/900.css'
Importing fonts in CSS:
@import '@fontsource/karla/400.css';
@import '@fontsource/karla/700.css';
@import '@fontsource/merriweather/400.css';
@import '@fontsource/merriweather/700.css';
@import '@fontsource/roboto-mono/400.css';
@import '@fontsource/roboto/500.css';
@import '@fontsource/roboto/700.css';
@import '@fontsource/roboto/900.css';
Fontsource supports variable fonts.
The dist
folder contains the following files:
Folder | For | File name |
---|---|---|
css |
both | globals.css |
css |
both | reset.css |
css |
plain css | base.css |
css |
plain css | colors-hex-*.css |
css |
plain css | typography.css |
css |
tailwind or web components | colors-rgb-*.css |
tailwind |
tailwind | base.css |
tailwind |
tailwind components | components.css |
tailwind |
tailwind typography components | typography.css |