Theming
How components follow your theme: colours, corner radius, and Solid and Frosted glass surfaces.
Thrum components have no colours of their own. They read the theme variables every shadcn project already defines, so an installed chart matches your buttons and cards from the first render. To restyle a component, change your theme, not the component.
Optional
The palette this site uses is a registry item, thrum-theme. Installing it rewrites the theme variables in your global stylesheet, for light and dark: the standard shadcn colours,--chart-6, --success, --warning and --radius. It adds no files. Nothing on this page depends on it.
npx shadcn@latest add https://thrumui.dev/r/thrum-theme.jsonTry the three choices
Three things change how every component looks: the colour theme, the surface material (Solid or Frosted glass) and the corner radius. You can tune all of them on any page from the Appearance studio in the top bar (or press A), or right here below. Pick Frosted glass to reveal the transparency and fog sliders plus the backdrop picker, and open the select to see a floating surface.
Theme
Surface
In your project
:root {
--radius: 8px;
}
<html class="dark">The variables components read
All of these are standard shadcn theme variables. A component never needs a variable from us.
| Variable | Used for |
|---|---|
--chart-1 to --chart-5 | Series colours, in order. A chart with one series uses --chart-1. |
--foreground | The cursor line of a chart, and a status mark in its normal range. |
--muted-foreground | Axis labels, the label in a readout, the “No data” text, and any series past the palette. |
--background | The 2 px ring around a mark that sits on another mark, such as the cursor dot on a line. |
--border | Value lines behind the data, the empty track of a meter, and the edge of a readout or a card. |
--card, --card-foreground | The surface and text of a stat card, an activity feed and the blocks. |
--popover, --popover-foreground | The readout that follows the cursor. |
--primary, --primary-foreground | The selected segment of a segmented control, and its text. |
--muted | The track of a segmented control, and a legend item under the pointer. |
--input | The edge of a segmented control. |
--ring | The focus ring. |
--destructive | A status mark in its critical range. |
--radius | The corner radius of every component (0 to 24 px), through the rounded utilities. Zero makes everything square. |
Three more are optional and have fallbacks: --chart-6, --success and --warning. They are covered below. No component reads anything outside this list.
Components use Tailwind utilities for the same variables where a class is enough (text-muted-foreground, bg-popover, ring-ring). There are no hex values in component code except the two fallbacks below.
How series colours map to the chart variables
Colours are given out in order and never cycled, so a colour always means the same series:
| Series | Colour | On this site |
|---|---|---|
| 1 | var(--chart-1) | |
| 2 | var(--chart-2) | |
| 3 | var(--chart-3) | |
| 4 | var(--chart-4) | |
| 5 | var(--chart-5) | |
| 6 | var(--chart-6, var(--muted-foreground)) | |
| 7 and up | var(--muted-foreground) |
- A shadcn theme defines five chart colours. If yours also defines
--chart-6, the sixth series uses it; otherwise the sixth is drawn in the neutral text colour. - From the seventh series on, everything is neutral. More than five series is usually a sign to group the rest as “Other”.
- Charts with one series take a
colorprop. Pass another theme variable to move a chart to a different slot:
<BarChart data={data} label="Errors" color="var(--chart-3)" />Choose five chart colours that differ in lightness as well as hue, and check each against --background: a mark needs a contrast of 3:1 or better to be read. Accessibility has the details.
Dark mode
There is nothing to switch on. Components contain no dark-mode classes: they read the variables, and your theme gives those variables different values in dark mode. However your project switches themes (a .dark class, a data attribute, the system setting), the components follow.
If it goes wrong
A line that disappears in dark mode means --chart-1 has no dark value, or one too close to the dark background. Define every chart variable in both themes.
Status colours: success and warning
Meters and other marks that mean good or bad use four status colours from lib/thrum-chart.ts. Two of them come from variables that not every shadcn theme has, so each carries a fallback:
| Status | Colour |
|---|---|
| normal | var(--foreground) |
| ok | var(--success, #1f9d55) |
| warn | var(--warning, #b87a00) |
| alarm | var(--destructive) |
The fallbacks are fixed colours, the same in light and dark. They are mid-tones chosen to show on a light and on a dark background, but they are not your palette. Define the two variables next to the rest of your theme and the components pick them up. For example, with the values this site uses:
:root {
--success: #146c3a;
--warning: #a97500;
}
.dark {
--success: #57d38c;
--warning: #cf9105;
}Status is never shown by colour alone. A component that uses these colours also shows the state as a word or a shape.
Corners: square, round, or anything between
Every corner in the library follows one number, your theme’s --radius (from 0 up to 24px). Set it to 0 and every component is square. Raise it and buttons, fields, cards, dialogs, menus and chart marks all get rounder together. No component has a radius of its own, so there is nothing to override one by one.
:root {
--radius: 0; /* square */
--radius: 0.25rem; /* the Thrum default, 4 px */
--radius: 0.75rem; /* round, 12 px */
}| Shape | What it takes |
|---|---|
| Buttons, fields, menu items, toggles | rounded-md |
| Small parts inside a control: chips, keys, checkbox boxes | rounded-sm |
| Cards, dialogs, popups, panels | rounded-lg |
| Large sheets | rounded-xl |
| Pills: switch tracks, badges, avatars, progress tracks | a pill at any radius above zero, square at zero |
| Data marks: bar ends, heatmap cells, legend swatches | your radius, capped at 2 px |
| True circles: a radio mark, a spinner, a status dot | always round |
- The
rounded-smtorounded-xlutilities are the ones your shadcn theme already derives from--radius, so the steps between a chip, a button and a card are yours too. - Data marks stop at 2 px on purpose: a bar with a 12 px corner no longer shows where its value ends.
- To change the radius at run time, set the variable on the root element:
document.documentElement.style.setProperty("--radius", "12px"). Charts redraw their marks when it changes.
Surfaces: solid and frosted glass
Components mark their surfaces and keep a solid colour by default. The markers stay inert until you install thrum-material, which adds the pure CSS frosted glass rules to your global stylesheet.
npx shadcn@latest add https://thrumui.dev/r/thrum-material.jsonThen choose a material with one attribute on the root element, or on a scoped container:
| Material | Set | What you get |
|---|---|---|
| Solid | nothing | Surfaces keep their theme colour. This is the default. |
| Frosted glass | data-material="frosted" | The surface colour, 45 % see-through, over a 20 px blur of what is behind it. |
export default function RootLayout({ children }) {
return (
<html lang="en" data-material="frosted">
<body>{children}</body>
</html>
);
}Frosted glass is pure CSS backdrop-filter. No extra provider, script or runtime filter is required.
Frosted glass controls
Two CSS variables tune frosted glass live through normal CSS inheritance on :root, any ancestor, or an individual surface. Leave either variable unset to use the frosted default (45% transparency and 20px fog).
:root {
--thrum-glass-transparency: 45%; /* 0% is solid, 100% is clear */
--thrum-glass-fog: 20px; /* interior blur radius (0 to 40 px) */
}| Variable | Default | Scope & effect |
|---|---|---|
--thrum-glass-transparency | 45% | Surface translucency from 0% (solid) to 100% (fully clear).Inherited via CSS from :root, any ancestor, or a surface. |
--thrum-glass-fog | 20px | Interior backdrop blur radius in pixels (0 to 40 px).Inherited via CSS from :root, any ancestor, or a surface. |
- At the default values, text keeps a contrast of 4.5:1 over any backdrop, from black to white. A test checks this against the theme’s real colours. Clearer glass than the default gives that promise up, so check your text over your own backdrop.
- On a dark theme the glass dims what is behind it; on a light theme it lifts and flattens it. That is what keeps text readable on a busy photograph.
The four markers
| Marker | Goes on | Under glass |
|---|---|---|
data-surface="floating" | A dialog, a menu, a popup, a tooltip | Always its own pane of glass, even on top of another surface. |
data-surface="panel" | A card, a bar, a sidebar | A pane of glass. Inside another surface it joins that sheet and adds no second blur. |
data-surface="control" | A button, a field, a tab list, a switch | Small glass, clearer than a sheet. Inside a surface it only thins its fill. |
data-surface="accent" | A filled button, a ticked checkbox | Keeps its colour and only catches the light. |
Your own elements join in with the same markers:
<div data-surface="floating" className="rounded-lg border bg-popover p-4">…</div>
<aside data-surface="panel" className="rounded-lg border bg-card p-4">…</aside>
<button data-surface="control" className="rounded-md border bg-background px-3 py-1.5">…</button>- The material is independent of the theme: Solid and Frosted glass both work in light and dark, and with any corner radius.
- Glass needs something behind it. On a flat page a glass surface looks almost solid. Keep the page itself plain and put a photograph or a soft colour field in a frame behind the glass, the way the stages on this site do.
- A component with no marked surface of its own, such as a label or a chart, takes the glass of whatever marked element it sits in: its fills thin out with that sheet.
- Visitors who ask their system for less transparency or more contrast get solid surfaces, and forced-colours mode uses system colours. Nothing to set up.
The photographs in the frames of this site are by Paul Pastourmatzis, Charles Postiaux, mingwei dong, Jeremy Bishop, Carles Rabada, Mikk Tõnissoo, Timon Jenny, Condor Wei, from Unsplash.
Sizing with className
Every component takes className on its root element and fills the box it is given. A class you pass wins over the default. Charts measure their container and redraw when it changes size, so they work in a grid, a resizable panel or a sidebar without a fixed width.
<BarChart data={data} label="Revenue" className="h-40" />
<Sparkline data={trend} label="Revenue, last 30 days" className="h-6 w-20" />
<AnimatedNumber value={12831} className="text-5xl font-semibold" />- Charts are full width and 256 px tall by default. Give them a height class, or a parent with a set height and
h-full. - The sparkline is 96 by 32 px by default and sits in a line of text like a word.
- The animated number is text: size and weight come from text utilities, and it inherits the font and colour around it.
- Components are built to draw sensibly down to a container 160 px wide.
Axis and readout text inside charts is 12 px with fixed-width digits and inherits your font family.