Theming
Radiant UI ships one accessible, carefully tuned default. The optional Radiant Themes package adds complete visual presets, each with its own palette, typography, spacing, shape, and component styling.
Choose a visual theme
Preview each theme with its own colors, typography, spacing, shape, and component details. Build your own, with fonts and a copyable setup, in the theme lab.
Try every theme on all components at once, pick fonts, and copy the install command and CSS for your choice in the theme lab.
Start with Radiant Default
Import the default theme and the component stylesheet in the application entry stylesheet. The default uses a cool, soft neutral palette, near-Zed spacing (28, 32, and 36px controls), restrained corners, flat controls, and visible translucent borders.
@import 'tailwindcss';
@import '@ecopages/radiant-ui/themes/default';
@import '@ecopages/radiant-ui/styles.css';Without Tailwind in your build
@import 'tailwindcss' needs Tailwind CSS v4 in your build. An app that does not run Tailwind imports Radiant UI's
compiled copy in its place: @ecopages/radiant-ui/radiant-ui-core.css holds Tailwind's base styles and theme variables
and the utility classes Radiant UI's components use, with no theme and no component styles.
@import '@ecopages/radiant-ui/radiant-ui-core.css';
@import '@ecopages/radiant-ui/themes/default';
@import '@ecopages/radiant-ui/styles.css';@ecopages/radiant-ui/radiant-ui.css is the same core with Radiant Default already included, so it replaces the first
two lines. Import the core or tailwindcss, never both: when your app uses Tailwind itself, keep @import 'tailwindcss',
because the core holds only the utilities Radiant UI needs, not the ones your markup uses.
Install a complete theme
Install @ecopages/radiant-ui and @ecopages/radiant-themes to use GitHub, Cloudflare, VS Code, Vercel, Material Design,
High Contrast, Windows 95, Mac OS Classic, macOS, or Zed. Each theme owns its component shape, typography, spacing, colors,
and any component-specific details.
pnpm add @ecopages/radiant-ui @ecopages/radiant-themes@import 'tailwindcss';
@import '@ecopages/radiant-themes/github';
@import '@ecopages/radiant-ui/styles.css';Compact entries are named per optional theme, such as github/compact and windows95/compact. For Radiant Default,
import @ecopages/radiant-ui/tokens/spacing/compact after @ecopages/radiant-ui/themes/default. Optional theme
entries reuse that theme's layer composition internally and apply the compact spacing preset; shared density changes
do not alter a branded theme's shape.
@import 'tailwindcss';
@import '@ecopages/radiant-themes/material/compact';
@import '@ecopages/radiant-ui/styles.css';The theme lab previews every full theme across all components. Theme, mode, fonts, and Radiant Default
tuner values are saved in the browser and can be shared with rui-theme, rui-mode, rui-font-sans,
rui-font-heading, rui-font-mono, and rui-* tuning query parameters. URL parameters override saved values, so
reloading a shared link keeps the same appearance. The seven tuner parameters are rui-primary-hue, rui-secondary-offset, rui-neutral-hue, rui-neutral-tint, rui-density,
rui-radius, and rui-border-alpha. Each theme import sets its own --font-sans, --font-heading, and --font-mono
stacks. Radiant does not bundle font files;
to use a custom licensed font, load it in your app and override those three variables:
@font-face {
font-family: 'Product Sans';
src: url('/fonts/product-sans.woff2') format('woff2');
font-display: swap;
}
:root {
--font-sans: 'Product Sans', system-ui, sans-serif;
--font-heading: var(--font-sans);
--font-mono: ui-monospace, monospace;
}High Contrast targets AAA contrast for published semantic text pairs and strengthens focus indicators. The default also responds to reduced-motion, increased-contrast, and Windows forced-colors preferences. Check the whole interface after custom role overrides, especially non-text boundaries and content supplied by your application.
Tune Radiant Default
Make a custom theme
Define semantic color roles in a stylesheet loaded after the base theme. Components consume semantic roles such as
--primary and --on-surface, not raw palette steps.
:root {
--primary: oklch(52% 0.19 264);
--on-primary: oklch(100% 0 0);
--primary-container: oklch(93% 0.04 264);
--on-primary-container: oklch(30% 0.11 264);
--background: oklch(98.2% 0.004 265);
--on-background: oklch(22% 0.008 265);
--surface: oklch(96% 0.006 265);
--on-surface: var(--on-background);
--border: oklch(74% 0.012 265 / 20%);
--focus-ring: var(--primary);
}Dark mode
Every theme, Radiant Default included, writes each color that differs in dark mode as light-dark(<light>, <dark>), so
components follow the color-scheme of the element they sit in. The root sets color-scheme: light dark, so with no
marker the page follows the system setting and needs no script. .dark sets color-scheme: dark and .light sets
color-scheme: light, which keeps existing <html class="dark"> markup working. Any other convention works by setting
color-scheme on any ancestor; the theme tokens read it where they are used. A switch that offers a fixed light mode
must pin it (.light or color-scheme: light), because removing .dark now leaves the page following the system.
A class, which radiant-ui already handles:
<html class="dark"></html>A data attribute that sets the scheme:
[data-theme='dark'] {
color-scheme: dark;
}
[data-theme='light'] {
color-scheme: light;
}A Tailwind @custom-variant, so dark: utilities and theme colors follow the same marker:
@custom-variant dark (&:where([data-theme='dark'], [data-theme='dark'] *));
[data-theme='dark'] {
color-scheme: dark;
}
[data-theme='light'] {
color-scheme: light;
}A section with its own color-scheme restyles the components inside it, so a light region inside a dark page
resolves light values. To retheme, override the roles (--primary, --surface), not the --color-* aliases; a role
that differs in dark mode is a light-dark() pair too.
Save the visitor's choice
ColorSchemeController from @ecopages/radiant-ui/controllers saves system, light or dark, sets color-scheme
and the .dark or .light class on <html>, and follows the system while system is chosen. Name another marker
with attribute: 'data-theme' or apply(resolved, target). Put colorSchemeBootScript from
@ecopages/radiant-ui/helpers inline in <head>, with the same options, so the saved scheme applies before first
paint. See ColorSchemeController and the color scheme helpers.
const scheme = createColorSchemeController(this, { attribute: 'data-theme' });
scheme.set('dark'); // color-scheme: dark, class="dark", data-theme="dark", saved
scheme.get(); // { value: 'dark', system: 'light', resolved: 'dark' }Toggle light/dark mode in the docs header to inspect every theme in both schemes. See Tokens for the semantic roles and scales.