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:
@import "tailwindcss";
@import "@astronomic-dev/ui/tokens.css";
@import "@astronomic-dev/ui/theme.css";| File | What it does |
|---|---|
tokens.css | Sets the core tokens' values, in light and dark. These values are the default look, Minimal. |
theme.css | Turns 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:
: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.
| Token | Light | Dark | Note |
|---|---|---|---|
--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 | #6f6f6f | text-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-amount | 82% | Same | |
--ui-accent-hover-mix | white | black | |
--ui-tint | #f1f1f1 | #1f1f1f | |
--ui-tint-fg | #171717 | #ededed | |
--ui-danger | #c9252d | #ff6b6b | |
--ui-scrim | #171717 | #0a0a0a | a dark veil over images, in both modes (CardOverlay) |
--ui-scrim-fg | #ffffff | #ededed |
Shape
Corner radii, edge widths and shadows.
| Token | Light | Dark |
|---|---|---|
--ui-radius-control | 8px | Same |
--ui-radius-card | 12px | Same |
--ui-radius-media | 6px | Same |
--ui-card-media-inset | 12px | Same |
--ui-border-w | 1px | Same |
--ui-media-border-w | 1px | Same |
--ui-shadow | none | Same |
--ui-button-shadow | inset 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.
| Token | Value | Note |
|---|---|---|
--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-weight | 550 | |
--ui-heading-weight | 550 | |
--ui-display-track | -0.042em | |
--ui-display-stretch | 100% | font-stretch for display type, e.g. 118% (expanded) or 75% (condensed) |
--ui-display-case | none | text-transform for display type, e.g. uppercase |
--ui-display-scale | 0.94 | multiplies the large display sizes (the display, title, section, stat, step, quote and price roles) |
--ui-type-display | clamp(2.5rem, 1.25rem + 6cqi, 4.75rem) | |
--ui-type-display-split | clamp(2.5rem, 1.25rem + 11cqi, 4.75rem) | |
--ui-type-title | clamp(2rem, 1rem + 6cqi, 4rem) | |
--ui-type-section | clamp(1.75rem, 1rem + 3cqi, 2.75rem) | |
--ui-type-stat | 4.5rem | |
--ui-type-step | clamp(2rem, 1rem + 8cqi, 3rem) | |
--ui-type-price | clamp(2rem, 1rem + 8cqi, 3.5rem) | |
--ui-type-quote | clamp(1.75rem, 1rem + 4cqi, 2.75rem) | |
--ui-type-subhead | clamp(1.375rem, 1rem + 2cqi, 1.75rem) | |
--ui-type-heading | 1.125rem | |
--ui-type-lead | 1.125rem | |
--ui-type-reading | 1.0625rem | |
--ui-type-body | 0.9375rem | |
--ui-type-small | 0.9rem | |
--ui-type-eyebrow | 0.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.
| Token | Value |
|---|---|
--ui-space | 4px |
--ui-control-h | 34px |
--ui-button-weight | 500 |
--ui-button-case | none |
--ui-button-track | 0em |
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.