--- title: "Tokens" pageTitle: "Fylgja Tokens" description: "Establish a consistent design language across your projects with Fylgja Design Tokens" npm: "@fylgja/tokens" git: "https://github.com/fylgja/fylgja/tree/main/tokens" sortOrder: 2 --- Establish a consistent design language across your projects with Fylgja Design Tokens. This predefined set of tokens eliminates redundant variations in spacing, colors, and other design elements, ensuring a unified structure throughout your codebase. For projects with specific requirements, Fylgja offers granular imports. Select only the necessary token categories, such as spacing, and define your own custom color palettes. Furthermore, Fylgja seamlessly integrates with [PostCSS Jit Props], mirroring the functionality of [Open Props](https://open-props.style/) and other design token systems, for optimized CSS output. ## Installation You can install Fylgja Tokens via npm or other Node-based package managers like pnpm or bun: ```bash npm install @fylgja/tokens ``` Alternatively, you can use it directly via a CDN: ```html ``` ## Usage Once installed, you can import the full package with: ```js import tokens from "@fylgja/tokens"; ``` or as CSS with: ```css @import "@fylgja/tokens/css"; ``` Next to this we also offers imports for SCSS, JS and for design systems in a json format. Each option can be import for all tokens or just the part you need. | Import Path | Description | | ---------------------------------------------------- | ----------------------------------------------- | | `@fylgja/tokens/{css/scss/tailwind}` | All tokens | | `@fylgja/tokens/{css/scss/tailwind/js}/aspect-ratio` | Aspect Ratios | | `@fylgja/tokens/{css/scss/js}/borders` | Border Widths and Radii | | `@fylgja/tokens/{css/scss/js}/colors` | List of 14 colors in oklch format | | `@fylgja/tokens/{css/scss}/hues` | JS version is part of the colors import | | `@fylgja/tokens/{css/scss}/colors-static` | Combination of colors and hues as a static list | | `@fylgja/tokens/tailwind/colors` | Same as `colors-static` | | `@fylgja/tokens/{css/scss/tailwind/js}/easing` | Easing Functions | | `@fylgja/tokens/{css/scss/js}/fonts` | Font Size and Line Height | | `@fylgja/tokens/{css/scss/tailwind/js}/mq` | CSS Breakpoints and User preferences | | `@fylgja/tokens/{css/scss/tailwind/js}/shadows` | Shadows | | `@fylgja/tokens/{css/scss/tailwind/js}/sizes` | Sizes | | `@fylgja/tokens/{css/scss/js}/z-layer` | Z-Index's | > [!Note] > Not all tokens can be represented in a design system format. | Import Path for design system | Description | | ----------------------------- | ------------------------------------------------ | | `@fylgja/tokens/tokens` | Follows the [(draft) Design Tokens Spec] | | `@fylgja/tokens/figma` | Can be used with the Figma Plugin [Token Studio] | [(draft) Design Tokens Spec]: https://design-tokens.github.io/community-group/format/ [Token Studio]: https://tokens.studio/ ### Shadow DOM Support For web components utilizing Shadow DOM, import the `.host` variants to apply tokens within the host scope: ```css @import "@fylgja/tokens/css/aspect-ratio.host"; ``` This enables seamless integration of Fylgja Design Tokens within your custom web components. ### PostCSS Jit Props Integration Leverage [PostCSS Jit Props] to optimize CSS output by including only the tokens used in your project. While Fylgja tokens are designed for minimal size, this integration further reduces file sizes, especially when combined with custom tokens. [PostCSS Jit Props]: https://github.com/GoogleChromeLabs/postcss-jit-props ### Tailwind Support The Fylgja Tokens also have a dedicated import options for TailwindCSS v4, specifically curated to augment or override relevant tokens within TailwindCSS's default theme settings. ## Previews ### Aspect-Ratio
Box
Landscape
Portrait
Widescreen
Superwide
ultrawide
Golden Ratio
### Border Radius
1
2
3
4
5
6
Full
#### Conditional Functions identically to the preceding numbered examples, except that this value reverts to 0 when the element's boundaries intersect with the screen edges. ### Border Sizes
1
2
3
4
5
6
### Colors Unlike other approaches where colors are predefined, we offer a dynamic color map. This map defines ranges of colors that can be modified using the `--hue` or `--chroma` variables. This approach minimizes the amount of CSS required for color definitions. It simplifies color implementation by defining only the color strength (`--color-{NUMBER}`) and a `--hue`. We also provide a set of predefined hues for convenience.
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
### Easing Achieve smooth and natural animations with five robust timing functions: ease, ease-out, ease-in, and ease-in-out. Go beyond the basics with advanced easing options with the elastic motion.
1
2
3
4
5
Play Animation
### Fonts

Easily customize your text with variable and static font sizes, intelligently adjusted line heights, modern font stacks, and a comprehensive set of typography variables.

### Mq (Media Queries) Stay ahead of the curve with FylgjaCSS's named media queries leveraging the `@custom-media` syntax even before its official [CSS specification] adoption. This powerful feature is implemented for CSS through the [PostCSS plugin Custom Media] and is also available as SCSS variables. [PostCSS plugin Custom Media]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-custom-media [CSS specification]: https://drafts.csswg.org/mediaqueries-5/#at-ruledef-custom-media #### Viewport Size / Orientation ```css --{sm,md,lg,xl,xxl}: (width >= *); --{sm,md,lg,xl,xxl}-max: (width < *); --portrait: (orientation: portrait); --landscape: (orientation: landscape); ``` #### Capabilities / Input ``` --touch: (hover: none) and (pointer: coarse); --stylus: (hover: none) and (pointer: fine); --pointer: (hover) and (pointer: coarse); --mouse: (hover) and (pointer: fine); ``` #### System Preferences ```css --hd-color: (dynamic-range: high); --scheme-{dark,light}: (prefers-color-scheme: *); --motion-{safe,reduce}: (prefers-reduced-motion: *); --opacity-{safe,reduce}: (prefers-reduced-transparency: *); --data-{safe,reduce}: (prefers-reduced-data: *); --contrast-{more,less}: (prefers-contrast: *); ``` ### Shadows
1
2
3
4
5
6
### Sizes Fylgja includes a comprehensive numeric spacing scale characterized by its proportional values. This ensures predictable and consistent spacing relationships within the design system. ```css --size-{1-10} --size-{12,14,16,18,20,24,28,32,36} --size-{40,50,60,70,80,90,100,120} --size-heading --size-content ``` ### Z-Layer Z-indexes don't need high values, just a currated list of values. If you need a higher z-index then your probley trying to override an exciting behavior and should consider refactoring the z-index values or wrap the z-indexes inside a new stacking layer. | Name | Usage examples | | ----------- | ------------------------------------------ | | `--layer-1` | Visible Stack item or overlaping elements | | `--layer-2` | 2de level of overlaping elements | | `--layer-3` | Sticky elements, e.g. Back To Top Button | | `--layer-4` | Fixed elements, e.g. Page Header or Appbar | | `--layer-5` | Top Layer elements, e.g. Dialogs or Modals |