Theming
AsheeUI's theming system is CSS-variable-driven, giving you full control over colors across your entire application. It ships with two built-in themes (light and dark) plus a system option that follows the user's operating system preference.
Import
Built-in themes
These are the default color tokens available out of the box. Each token maps to a CSS custom property that components use internally.
| Token | Light | Dark | Description |
|---|---|---|---|
background | #ffffff | #111111 | Main page background |
foreground | #000000 | #ffffff | Primary text color |
primary | #2563eb | #005bc4 | Brand color / interactive elements |
secondary | #ffffff | #1a1a1a | Secondary surfaces (cards, panels) |
border | #d5d5d5 | #2a2a2a | Borders and dividers |
danger | #dc2626 | #ef4444 | Error / destructive actions |
warning | #d97706 | #f59e0b | Warning states |
success | #16a34a | #22c55e | Success states |
scrollbarThumb | #3b82f6 | #1e40af | Scrollbar thumb color |
scrollbarTrack | transparent | #1f293700 | Scrollbar track color |
Setting the default theme
Define defaultTheme in asheeui.config.ts:
"light": Always use light theme"dark": Always use dark theme"system": Follow the user's OS preference (default)
Switching themes at runtime
Use the useTheme hook to read and change the current theme:
Return values
| Property | Type | Description |
|---|---|---|
theme | ThemeSelection | Current selected theme ("light" | "dark" | "system") |
resolvedTheme | ThemeName | Actual resolved theme (after system fallback) |
setTheme | (theme: ThemeSelection) => void | Set the active theme |
toggleTheme | () => void | Cycle to the next theme in sequence |
availableThemes | readonly string[] | All registered theme names |
Note: Theme preference persists across page reloads via localStorage.
Customizing a built-in theme
Override specific color tokens for light or dark without creating a new theme:
Only the tokens you specify are overridden, everything else stays at the built-in default.
Adding a custom theme
Define a new named theme that extends light or dark and overrides specific tokens:
When you extend a built-in theme, you only need to specify the tokens you want to change. All others inherit from the parent.
Note: If you're using TypeScript, you need to register the custom theme name so useTheme and setTheme recognize it: