Fylgja Tokens
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 and other design token systems, for optimized CSS output.
Installation
npm install @fylgja/tokens pnpm add @fylgja/tokens npx fylgja@latest add tokens This copies the file directly into your project. The import path will differ from the one shown in the usage section below.
<link href="https://cdn.jsdelivr.net/npm/@fylgja/tokens/css/index.min.css" rel="stylesheet"> Usage
Once installed, you can import the full package with:
import tokens from "@fylgja/tokens";
or as CSS with:
@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}/index.{css/scss} | All tokens |
@fylgja/tokens/{css/scss/tailwind/js}/aspect-ratio.{css/scss/js} | Aspect Ratios |
@fylgja/tokens/{css/scss/js}/borders.{css/scss/js} | Border Widths and Radii |
@fylgja/tokens/{css/scss/js}/colors.{css/scss/js} | List of 14 colors in oklch format |
@fylgja/tokens/{css/scss}/hues.{css/scss} | JS version is part of the colors import |
@fylgja/tokens/{css/scss}/colors.static.{css/scss} | Combination of colors and hues as a static list |
@fylgja/tokens/tailwind/colors.css | Same as colors-static |
@fylgja/tokens/{css/scss/tailwind/js}/easing.{css/scss/js} | Easing Functions |
@fylgja/tokens/{css/scss/js}/fonts.{css/scss/js} | Font Size and Line Height |
@fylgja/tokens/{css/scss/tailwind/js}/mq.{css/scss/js} | CSS Breakpoints and User preferences |
@fylgja/tokens/{css/scss/tailwind/js}/shadows.{css/scss/js} | Shadows |
@fylgja/tokens/{css/scss/tailwind/js}/sizes.{css/scss/js} | Sizes |
@fylgja/tokens/{css/scss/js}/z-layer.{css/scss/js} | 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 |
Shadow DOM Support
For web components utilizing Shadow DOM,
import the .host variants to apply tokens within the host scope:
@import "@fylgja/tokens/css/aspect-ratio.host.css";
This enables seamless integration of Fylgja Design Tokens within your custom web components.
All token categories except colors, colors.static, mq, and shadows provide a .host variant.
These four don’t need one: they aren’t scoped to :root, so they already apply everywhere,
including inside the Shadow DOM, without a separate host-scoped import.
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.
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
Border Radius
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
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.
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.
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.
Viewport Size / Orientation
--{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
--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
Sizes
Fylgja includes a comprehensive numeric spacing scale characterized by its proportional values. This ensures predictable and consistent spacing relationships within the design system.
--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 |
FAQ
Do I need to import all the tokens, or can I pick just what I need?
You can import everything with the full package, or import only the categories you need (e.g. just colors or sizes) using the granular import paths listed above. Each category is available separately in CSS, SCSS, and JS formats.
Do Fylgja Utilities or Components require Fylgja Tokens to work?
No, they're independent. Fylgja Utilities and Components use CSS variables that Fylgja Tokens happen to provide sensible values for, but you can supply your own values (or use a system like Open Props) instead.
How do I change a color's hue or intensity?
Colors are defined as a dynamic map rather than fixed swatches. Set the --hue variable to one of the predefined hues (e.g. var(--hue-teal)) and use --color-{0-14} for strength. You can also adjust --chroma to change color intensity.
What's the difference between colors.css and colors.static.css?
colors.css is the dynamic map driven by --hue/--chroma. colors.static.css (and the Tailwind colors.css import, which is the same thing) is a fixed list combining colors and hues, useful when you don't need the dynamic hue-switching behavior.
What does the PostCSS Jit Props integration actually do?
It scans your compiled CSS and only outputs the token variables you actually use, instead of the full token set. This keeps your final CSS smaller, especially useful if you're also defining a lot of your own custom tokens.
Do I need Fylgja Tokens if I'm already using Open Props?
Not necessarily. Fylgja Tokens is designed to integrate with the same tooling (PostCSS Jit Props) and follow the same conventions as Open Props, so you can mix and match or pick whichever token source fits your project.