DocumentationTokens

Open in Create
Search
astronomic.dev

Tokens

The --ui-* CSS variables that set the colors, shapes, type and spacing of every part.

A token is a CSS variable whose name starts with --ui-, such as --ui-accent or --ui-radius-card. Parts in Astronomic UI take their colors, corners, fonts and spacing from these tokens.

So you restyle the kit by changing token values, not a part's markup or classes. A few things stay fixed by design: an Avatar is always round, in its own fixed sizes.

Where tokens live

The kit ships two CSS files. Your site's main CSS file imports both, in this order:

css
@import "tailwindcss";
@import "@astronomic-dev/ui/tokens.css";
@import "@astronomic-dev/ui/theme.css";
FileWhat it does
tokens.cssSets the core tokens' values, in light and dark. These values are the default look, Minimal.
theme.cssTurns the tokens into Tailwind classes, such as bg-accent, text-fg, rounded-card and font-display.

A preset is a third file that changes some of the values. It goes after tokens.css.

How parts read tokens

Parts style themselves with the Tailwind classes that theme.css makes from the tokens. A card uses rounded-card, which reads --ui-radius-card. A primary button uses bg-accent, which reads --ui-accent.

No part names a fixed color or font, and no part uses Tailwind's dark: variant. Dark mode swaps the token values instead. See Dark mode.

Use the same classes in your own markup, so your pages follow the preset too.

Change a token

Set the token on :root in your main CSS file, after the kit's imports. A color needs a light value and a dark value:

css
:root {
  --ui-accent: #6a3be0;
  --ui-accent-fg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ui-accent: #9a7cff;
    --ui-accent-fg: #170b36;
  }
}
:root[data-theme="dark"] {
  --ui-accent: #9a7cff;
  --ui-accent-fg: #170b36;
}

The two dark blocks cover both ways a page turns dark: the reader's system setting, and a choice saved by the light and dark switch.

You can also set a token on one element. Everything inside it takes the new value, so one section can have its own accent or spacing.

Tip

Change colors in pairs. A token that ends in -fg is the text color on its partner: --ui-accent-fg on --ui-accent, --ui-scrim-fg on --ui-scrim. Text needs 4.5:1 contrast on its partner. Create checks the contrast as you edit.

The groups

The tables below come straight from tokens.css. They show the default look, Minimal. Where a token has no dark value, it keeps its light value in dark mode. A few tokens are set only in dark, such as --ui-media-dim, which dims image frames.

Color

The page, the surfaces on it, text, edges, the accent and its states.

TokenLightDarkNote
--ui-bg#ffffff#0a0a0a
--ui-surface#ffffff#0f0f0f
--ui-surface-2#f4f4f4#1a1a1a
--ui-fg#171717#ededed
--ui-muted#666666#a1a1a1
--ui-border#e9e9e9#2e2e2e
--ui-border-control#8a8a8a#6f6f6ftext-field edges: 3:1 on bg, surface and surface-2
--ui-accent#171717#ededed
--ui-accent-fg#ffffff#0a0a0a
--ui-accent-soft#efefef#262626
--ui-accent-hover-amount82%Same
--ui-accent-hover-mixwhiteblack
--ui-tint#f1f1f1#1f1f1f
--ui-tint-fg#171717#ededed
--ui-danger#c9252d#ff6b6b
--ui-scrim#171717#0a0a0aa dark veil over images, in both modes (CardOverlay)
--ui-scrim-fg#ffffff#ededed

Shape

Corner radii, edge widths and shadows.

TokenLightDark
--ui-radius-control8pxSame
--ui-radius-card12pxSame
--ui-radius-media6pxSame
--ui-card-media-inset12pxSame
--ui-border-w1pxSame
--ui-media-border-w1pxSame
--ui-shadownoneSame
--ui-button-shadowinset 0 1px 0 rgb(255 255 255 / 0.2), 0 0 0 0.5px rgb(0 0 0 / 0.9), 0 1px 1px rgb(0 0 0 / 0.1)inset 0 -1px 0 rgb(0 0 0 / 0.14), 0 0 0 0.5px rgb(255 255 255 / 0.9)
--ui-media-dim—brightness(0.88)

Type

The two fonts, how display type is set, and the size of each kind of text (the type roles). The larger roles grow and shrink with their container.

TokenValueNote
--ui-font-display"Geist", "Geist Variable", ui-sans-serif, system-ui, sans-serif
--ui-font-body"Geist", "Geist Variable", ui-sans-serif, system-ui, sans-serif
--ui-display-weight550
--ui-heading-weight550
--ui-display-track-0.042em
--ui-display-stretch100%font-stretch for display type, e.g. 118% (expanded) or 75% (condensed)
--ui-display-casenonetext-transform for display type, e.g. uppercase
--ui-display-scale0.94multiplies the large display sizes (the display, title, section, stat, step, quote and price roles)
--ui-type-displayclamp(2.5rem, 1.25rem + 6cqi, 4.75rem)
--ui-type-display-splitclamp(2.5rem, 1.25rem + 11cqi, 4.75rem)
--ui-type-titleclamp(2rem, 1rem + 6cqi, 4rem)
--ui-type-sectionclamp(1.75rem, 1rem + 3cqi, 2.75rem)
--ui-type-stat4.5rem
--ui-type-stepclamp(2rem, 1rem + 8cqi, 3rem)
--ui-type-priceclamp(2rem, 1rem + 8cqi, 3.5rem)
--ui-type-quoteclamp(1.75rem, 1rem + 4cqi, 2.75rem)
--ui-type-subheadclamp(1.375rem, 1rem + 2cqi, 1.75rem)
--ui-type-heading1.125rem
--ui-type-lead1.125rem
--ui-type-reading1.0625rem
--ui-type-body0.9375rem
--ui-type-small0.9rem
--ui-type-eyebrow0.8125rem

Density and controls

--ui-space is the base unit for gaps and padding. When --ui-space-section, --ui-space-block and --ui-space-item are not set, the section, block and item gaps are multiples of it, so changing this one token makes the kit tighter or looser. A preset that sets those tokens fixes its own gaps.

TokenValue
--ui-space4px
--ui-control-h34px
--ui-button-weight500
--ui-button-casenone
--ui-button-track0em

Optional tokens

Some tokens are not in the tables, such as --ui-band (a full-width color band) or --ui-radius-pill. When they are not set, parts fall back to a value made from the tokens above.

A preset that wants that fallback sets the token to initial. Every kit preset does this for --ui-accent-hover-mix, which Minimal sets.

Waitlist

Be first in line

Join the waitlist and we'll email you the moment it's out.

You'll also get our newsletter: new themes, plugins and guides. Unsubscribe any time.