Skip to content
Gelatin UIAlpha

Change the theme

Change token values in your stylesheet to set the colors, radius, and fonts. Every component follows, in light and dark mode.

How items work · step 2 of 3 · 4 min read

Prompt for your agent

Read https://gelatinui.com/docs/theming.md. Then change the Gelatin UI theme of this project to our brand color, font, and radius. Change token values only, never names, in :root and .dark. Done when both modes show the brand and no component file changed.

Your agent reads /docs/theming.md: the same text as this page, as Markdown.

You change the look of every Gelatin UI component from one place: the theme variables in your stylesheet. Change a value, and every component that reads it follows.

How the theme works

The theme is a set of CSS variables with the shadcn names. The light values are in :root, and the dark values are in .dark. Each component reads only these variables. No component holds its own colors.

Add the theme once with the shadcn CLI:

Colors

Most colors come in pairs: a surface, and the text on that surface.

VariableUse
--background, --foregroundThe page and the text on the page.
--card, --card-foregroundA card or a panel.
--popover, --popover-foregroundA popup: a menu, a popover, a select list.
--primary, --primary-foregroundThe main action.
--secondary, --secondary-foregroundA second action.
--muted, --muted-foregroundA quiet surface, and quiet text.
--accent, --accent-foregroundA hover or a highlighted row.
--destructiveAn action that deletes or cannot be undone.
--border, --input, --ringLines, field edges, and the focus ring.
--chart-1 to --chart-5The series colors of a chart.
--sidebar and its pairsThe app sidebar.

Change a color

Set a new value in your stylesheet, for light and for dark. Change the value, not the name:

CSS

Dark mode

Put the dark class on <html> to show the dark values.

One part of a light page can be dark: put the dark class on that element, and its children follow it. For the other way round, a light part of a dark page, use inverse (below).

Inverse sections

The inverse class comes with the Gelatin UI theme. It gives an element the other mode: dark on a light page, light on a dark page. Every component inside follows: buttons, badges, fields, keys, and icons.

Use it on a whole section:

TSX

Or use it on one component, when only that component must stand out:

TSX

Follow these rules:

  • A section paints itself. Put bg-background text-foreground on the same element as inverse. The class changes only the tokens, so the element must paint with them. A component paints itself, so it needs nothing more.
  • The colors come with the tokens. The token items ship the inverse values. You add nothing for the colors.
  • Some components have an inverse variant. Tooltip, Toast, Announcement, Announcement Bar, and Ad use this class for it. Pick the variant, and the parts inside follow.

The dark variant

A few components use dark: classes for some colors. To make them follow an inverse section too, replace the dark variant line in your global CSS with this block:

CSS

Limits

  • Two levels. An inverse element inside another inverse element flips back, for example a tooltip in a featured card. A third level does not flip again.
  • Popups. A popup opens outside its trigger, so it does not get the mode of an inverse section. Put inverse on the popup itself when you need it.
  • Your own CSS. Read the base tokens (var(--foreground)), not the --color-* aliases. Code that reads the aliases keeps the outer colors.

Corner radius

--radius is the base corner radius (0.625rem). The radius scale, from rounded-sm to rounded-4xl, comes from it. Change --radius, and every corner follows.

Fonts

The theme does not change your fonts: your project keeps its own. Our components read --font-sans, --font-heading, and --font-mono. To use the fonts of our site, Hanken Grotesk for text and headings and Departure Mono for code (a free pixel mono font, OFL 1.1, from departuremono.com), load them in your app and add this block to your main stylesheet:

CSS

Status colors

Some components show a state: success, warning, info, or an error. These components add the status-colors item for you. It writes five tokens for each state:

  1. The solid color.
  2. The text on the solid color.
  3. A soft tint.
  4. The text on the tint.
  5. A border.

Next steps