Docs · Guide

Styling

Every visual value in astro-ui is a CSS custom property. There is no theme config — the tokens are the theming API.

The token model

Tokens live on :root (light) and[data-theme="dark"], grouped by role:

:root {
  /* surfaces */
  --ui-background: #ffffff;
  --ui-foreground: #18181b;
  --ui-muted: #f4f4f5;
  --ui-border: #e4e4e7;

  /* brand */
  --ui-primary: #2563eb;
  --ui-primary-foreground: #ffffff;

  /* feedback */
  --ui-success: #16a34a;
  --ui-warning: #d97706;
  --ui-error: #dc2626;

  /* shape & type */
  --ui-radius-md: 0.5rem;
  --ui-text-sm: 0.875rem;
  --ui-space-4: 1rem;
}

Components never hard-code colors — they read tokens. Variant classes (aui-badge--success, for example) just point at a different token.

Overriding tokens

Set the variables anywhere after the token import — your global CSS, a page, or an element. One override re-skins everything that reads it:

:root {
  --ui-primary: oklch(0.55 0.21 264);
  --ui-radius-md: 0.75rem;
}
Themed badge

(These two are themed by this site's brand layer — the same mechanism, overriding --ui-primary.)

Token playground

Edit any token and watch the preview panel — buttons, badges, an alert, a progress bar, and a donut cut from the chart palette. Overrides apply to the preview only (light theme), and the output is copy-ready CSS for your own stylesheet.

Surfaces
Brand
Feedback
Chart
Rating
Type
Shape & space
Controls
Elevation & motion
PrimaryActivePendingFailedNew

Heads up

Scheduled maintenance Sunday 02:00–04:00 UTC.
Uploading
Palette
One: 22 (22%)Two: 18 (18%)Three: 16 (16%)Four: 14 (14%)Five: 12 (12%)Six: 18 (18%)
CategoryShare
One22
Two18
Three16
Four14
Five12
Six18
No changes yet
/* Edit a token — overrides appear here as copy-ready CSS. */

Dark mode needs the same overrides under[data-theme="dark"] — this preview is light-only.

Dark mode

Dark values live under [data-theme="dark"]. Flip the attribute — before paint, to avoid a flash:

<script is:inline>
  const saved = localStorage.getItem("theme");
  if (saved) document.documentElement.dataset.theme = saved;
</script>

Utility classes

Components style themselves from tokens; compose layouts with your own utilities. The demo site uses a small utility layer plus Tailwind where convenient — but nothing in the library requires Tailwind. Class merging (the class prop on every component) keeps overrides clean.