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
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.
Change a color
Set a new value in your stylesheet, for light and for dark. Change the value, not the name:
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:
Or use it on one component, when only that component must stand out:
Follow these rules:
- A section paints itself. Put
bg-background text-foregroundon the same element asinverse. 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
inversevariant. 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:
Limits
- Two levels. An
inverseelement inside anotherinverseelement 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
inverseon 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:
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:
- The solid color.
- The text on the solid color.
- A soft tint.
- The text on the tint.
- A border.
Next steps
- Change motion: set the speed of every motion with one token.
- Connect the MCP server: ask your agent for a theme from your brand color, font, and radius.