Documentation
Theming
Light or dark, square to round, any highlight colour, from three attributes.
Try it
These switches set three attributes on this page. Everything on the site follows, and the choice is remembered.
The three attributes
<html data-theme="dark" data-radius="lg" data-accent="violet">| Attribute | Values |
|---|---|
data-theme | light, dark (or the class dark) |
data-radius | none, sm, md, lg, full (controls become pills) |
data-accent | teal, blue, violet, pink, red, orange, amber, green, ink |
The theme-provider component lets visitors switch and remembers their choice, without a flash of the wrong theme when the page loads.
Any colour, any roundness
Set --accent-hue (0 to 360), --accent-chroma (0 to about 0.25) and --radius yourself. Lightness is chosen by the theme, so text on the highlight colour keeps its contrast in both modes.
:root {
--accent-hue: 262;
--accent-chroma: 0.19;
--radius: 0.5rem;
}A theme for part of a page
The attributes work on any element, so one block can carry its own mode and colour whatever the page is set to.
Dark and violet, inside this page
<section data-theme="dark" data-accent="violet">…</section>A brand's own colours and fonts
They go in a block after the theme's import in the global stylesheet. Components are never edited to restyle them: they draw only from these variables.
@import "tailwindcss";
@import "tw-animate-css";
@import "../styles/rivier-ui.css";
:root {
--accent-hue: 28;
--accent-chroma: 0.17;
--radius: 0.75rem;
}The tokens
The names follow the shadcn convention. The whole stylesheet, with both modes, is the theme item.
| Utilities | For |
|---|---|
| bg-background, text-foreground | The page and its text. |
| bg-card, bg-popover | Surfaces: cards and dialogs, and what floats over the page. |
| bg-muted, text-muted-foreground | Quiet ground, and text that is secondary. |
| bg-accent | The ground under a hovered or highlighted row. |
| bg-primary, text-primary-foreground | The highlight colour, and text on it. |
| bg-highlight-soft | A tint of the highlight colour, for what is chosen or current. |
| border-border, border-border-strong, border-input | Edges: default, emphasised, and around controls. |
| bg-destructive, bg-success, bg-warning | States, each with a -foreground for text on it. |
| fill-chart-1 to fill-chart-5 | Series colours of charts, in a fixed, checked order. |
| rounded-control, rounded-surface | Corners of controls, and of surfaces. Both follow data-radius. |
| h-control, h-control-sm, h-control-lg | Heights of controls. |
| duration-instant, duration-base, duration-slow, ease-out | Motion. |