Skip to the content

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.

Mode
Roundness
Highlight

The three attributes

<html data-theme="dark" data-radius="lg" data-accent="violet">
AttributeValues
data-themelight, dark (or the class dark)
data-radiusnone, sm, md, lg, full (controls become pills)
data-accentteal, 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.

src/app/globals.css
@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.

UtilitiesFor
bg-background, text-foregroundThe page and its text.
bg-card, bg-popoverSurfaces: cards and dialogs, and what floats over the page.
bg-muted, text-muted-foregroundQuiet ground, and text that is secondary.
bg-accentThe ground under a hovered or highlighted row.
bg-primary, text-primary-foregroundThe highlight colour, and text on it.
bg-highlight-softA tint of the highlight colour, for what is chosen or current.
border-border, border-border-strong, border-inputEdges: default, emphasised, and around controls.
bg-destructive, bg-success, bg-warningStates, each with a -foreground for text on it.
fill-chart-1 to fill-chart-5Series colours of charts, in a fixed, checked order.
rounded-control, rounded-surfaceCorners of controls, and of surfaces. Both follow data-radius.
h-control, h-control-sm, h-control-lgHeights of controls.
duration-instant, duration-base, duration-slow, ease-outMotion.