Skip to content
Thrum
Docs · 05 of 09All pages

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.

Terminal
npx shadcn@latest add https://thrumui.dev/r/thrum-theme.json

Try 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

8 px

In your project

:root {
  --radius: 8px;
}

<html class="dark">
Checkout latency
What you pick on the left, on real components.

The variables components read

All of these are standard shadcn theme variables. A component never needs a variable from us.

VariableUsed for
--chart-1 to --chart-5Series colours, in order. A chart with one series uses --chart-1.
--foregroundThe cursor line of a chart, and a status mark in its normal range.
--muted-foregroundAxis labels, the label in a readout, the “No data” text, and any series past the palette.
--backgroundThe 2 px ring around a mark that sits on another mark, such as the cursor dot on a line.
--borderValue lines behind the data, the empty track of a meter, and the edge of a readout or a card.
--card, --card-foregroundThe surface and text of a stat card, an activity feed and the blocks.
--popover, --popover-foregroundThe readout that follows the cursor.
--primary, --primary-foregroundThe selected segment of a segmented control, and its text.
--mutedThe track of a segmented control, and a legend item under the pointer.
--inputThe edge of a segmented control.
--ringThe focus ring.
--destructiveA status mark in its critical range.
--radiusThe 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:

SeriesColourOn this site
1var(--chart-1)
2var(--chart-2)
3var(--chart-3)
4var(--chart-4)
5var(--chart-5)
6var(--chart-6, var(--muted-foreground))
7 and upvar(--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 color prop. Pass another theme variable to move a chart to a different slot:
A different series colour
<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:

StatusColour
normalvar(--foreground)
okvar(--success, #1f9d55)
warnvar(--warning, #b87a00)
alarmvar(--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:

Your global CSS
: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.

Your global CSS: pick one
:root {
  --radius: 0;        /* square */
  --radius: 0.25rem;  /* the Thrum default, 4 px */
  --radius: 0.75rem;  /* round, 12 px */
}
ShapeWhat it takes
Buttons, fields, menu items, togglesrounded-md
Small parts inside a control: chips, keys, checkbox boxesrounded-sm
Cards, dialogs, popups, panelsrounded-lg
Large sheetsrounded-xl
Pills: switch tracks, badges, avatars, progress tracksa pill at any radius above zero, square at zero
Data marks: bar ends, heatmap cells, legend swatchesyour radius, capped at 2 px
True circles: a radio mark, a spinner, a status dotalways round
  • The rounded-sm to rounded-xl utilities 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.

Terminal
npx shadcn@latest add https://thrumui.dev/r/thrum-material.json

Then choose a material with one attribute on the root element, or on a scoped container:

MaterialSetWhat you get
SolidnothingSurfaces keep their theme colour. This is the default.
Frosted glassdata-material="frosted"The surface colour, 45 % see-through, over a 20 px blur of what is behind it.
app/layout.tsx
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).

Your global CSS
:root {
  --thrum-glass-transparency: 45%; /* 0% is solid, 100% is clear */
  --thrum-glass-fog: 20px;         /* interior blur radius (0 to 40 px) */
}
VariableDefaultScope & effect
--thrum-glass-transparency45%Surface translucency from 0% (solid) to 100% (fully clear).Inherited via CSS from :root, any ancestor, or a surface.
--thrum-glass-fog20pxInterior 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

MarkerGoes onUnder glass
data-surface="floating"A dialog, a menu, a popup, a tooltipAlways its own pane of glass, even on top of another surface.
data-surface="panel"A card, a bar, a sidebarA 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 switchSmall glass, clearer than a sheet. Inside a surface it only thins its fill.
data-surface="accent"A filled button, a ticked checkboxKeeps its colour and only catches the light.

Your own elements join in with the same markers:

Your component
<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.

Sizes
<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.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor