Design Tokens
Use the theme's colors, sizes and spacing in your own CSS or Tailwind CSS utilities
StellarAdmin.UI derives design tokens from the theme variables. These are CSS variables that hold the colors, corner radii, spacing and shadows the components use. When you use them in your own CSS, your own elements match the theme, the density and dark mode.
Using the design tokens in your own CSS
To use a design token, read it with var(). The example below styles a trip summary with the design tokens:
.trip-summary {
padding: var(--sa-space-container);
border: var(--sa-border-width) solid var(--sa-color-line);
border-radius: var(--sa-radius-container);
background: var(--sa-color-surface);
color: var(--sa-color-ink);
}
.trip-summary small {
color: var(--sa-color-ink-muted);
}You can use the following design tokens:
| Used for | Design tokens |
|---|---|
| Page and cards | --sa-color-canvas (page), --sa-color-surface (cards, popovers), --sa-color-surface-subtle (footers, table headers), --sa-color-surface-sunken (tracks, chips) |
| Text | --sa-color-ink, --sa-color-ink-muted, --sa-color-ink-placeholder |
| Lines | --sa-color-line (dividers, borders of containers), --sa-color-line-control (borders of controls) |
| Accent | --sa-color-accent-fill (solid fills), --sa-color-on-accent (text on the solid fills), --sa-color-accent-text (text in the accent color) |
| Danger and status | --sa-color-danger-fill, --sa-color-on-danger, --sa-color-danger-text, --sa-color-success, --sa-color-warning, --sa-color-info |
| Hover and selection | --sa-color-hover, --sa-color-selected |
| Shape | --sa-radius-control, --sa-radius-container, --sa-radius-tag, --sa-border-width |
| Space | --sa-unit (0.25rem multiplied by the density), --sa-space-container, --sa-control-h |
| Type | --sa-font-sans, --sa-font-heading, --sa-font-mono, --sa-text-xs, --sa-text-sm, --sa-text-base |
| Shadows | --sa-shadow-container, --sa-shadow-overlay |
Don't set the design tokens. To change them, set the theme variables they're derived from. Other CSS variables, including any that start with --_, are internal and can change in any version.
Using the design tokens with Tailwind CSS
The StellarAdmin.UI stylesheet doesn't contain utility classes, so utility classes such as bg-primary and mt-4 only work if your app has its own Tailwind CSS v4 build. StellarAdmin.UI includes a Tailwind adapter, which makes Tailwind's utility classes use the design tokens.
To use the adapter, copy stellar-admin.tailwind.css from the package's static assets, at _content/StellarAdmin.UI/stellar-admin.tailwind.css, into your project, or reference it from where your build can read it. Then import it after Tailwind in your CSS, and declare the StellarAdmin.UI layer order first:
@layer theme, base, sa.reset, sa.tokens, sa.components, components, sa.theme, sa.overrides, utilities;
@import "tailwindcss";
@import "./stellar-admin.tailwind.css";The adapter doesn't contain any styles, so keep linking stellar-admin.css in your layout.
The adapter makes the following utility classes use the design tokens:
- The spacing utility classes, such as
p-4andgap-2, which follow the density. text-xs,text-sm,text-base,font-sans,font-mono,font-headingand therounded-*classes.- The colors, which have their shadcn/ui names, such as
bg-primary,text-primary-foreground,bg-card,bg-muted,text-muted-foreground,border-border,bg-accent,text-destructiveand thesidebar-*colors. - The
dark:variant, which follows thedarkclass.
The layer order puts Tailwind's base styles below the components, and your utility classes above them, so a utility class on a Tag Helper overrides the component's own style. The layer names and their order only change in a breaking release.
The first <div> below uses the colors from the adapter, so it matches the theme and dark mode. The second one uses Tailwind's own colors, so it doesn't:
<div class="rounded-xl border bg-card p-4 text-card-foreground">...</div>
<div class="rounded-xl border border-gray-200 bg-white p-4 text-gray-900">...</div>