---
title: "Change the theme"
description: "Change token values in your stylesheet to set the colors, radius, and fonts. Every component follows, in light and dark mode."
url: https://gelatinui.com/docs/theming
markdown_url: https://gelatinui.com/docs/theming.md
docs_index: https://gelatinui.com/docs/llms.txt
prompt: "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."
---

> Docs index: https://gelatinui.com/docs/llms.txt

# Change the theme

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

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:

```bash
npx shadcn@latest add @gelatin-ui/theme
```

## Colors

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

| Variable                                | Use                                         |
| --------------------------------------- | ------------------------------------------- |
| `--background`, `--foreground`          | The page and the text on the page.          |
| `--card`, `--card-foreground`           | A card or a panel.                          |
| `--popover`, `--popover-foreground`     | A popup: a menu, a popover, a select list.  |
| `--primary`, `--primary-foreground`     | The main action.                            |
| `--secondary`, `--secondary-foreground` | A second action.                            |
| `--muted`, `--muted-foreground`         | A quiet surface, and quiet text.            |
| `--accent`, `--accent-foreground`       | A hover or a highlighted row.               |
| `--destructive`                         | An action that deletes or cannot be undone. |
| `--border`, `--input`, `--ring`         | Lines, field edges, and the focus ring.     |
| `--chart-1` to `--chart-5`              | The series colors of a chart.               |
| `--sidebar` and its pairs               | The app sidebar.                            |

### Change a color

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

```css
:root {
  --primary: oklch(0.45 0.2 260);
}

.dark {
  --primary: oklch(0.75 0.15 260);
}
```

## 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
<section className="inverse rounded-2xl bg-background p-6 text-foreground">
  <h2>Get every Pro block</h2>
  <p>Pay once. New Pro items come to you too.</p>
  <Button>Get Pro</Button>
  <Button variant="outline">See pricing</Button>
</section>
```

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

```tsx
<Button className="inverse">Start free trial</Button>

<Alert variant="warning" className="inverse">
  <WarningIcon />
  <AlertTitle>Storage almost full</AlertTitle>
</Alert>

<Button>
  Generate
  <Badge variant="secondary" className="inverse">4 credits</Badge>
</Button>
```

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
@custom-variant dark {
  &:is(.dark *):not(.light *):not(:where(.dark .inverse *)) {
    @slot;
  }
  &:is(.light .dark *):not(:where(.dark .inverse *)) {
    @slot;
  }
  &:is(.inverse *):not(.dark *):not(:where(.inverse .light *, .inverse .inverse *)) {
    @slot;
  }
  &:is(.dark *):is(.inverse *):where(.inverse .inverse *) {
    @slot;
  }
  &:is(.dark *):is(.inverse *):where(.dark .light .inverse *) {
    @slot;
  }
}
```

### 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
@theme {
  --font-sans: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-heading: var(--font-sans);
  --font-mono: "Departure Mono", ui-monospace, monospace;
}
```

## 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

- [Change motion](https://gelatinui.com/docs/motion.md): set the speed of every motion with one token.
- [Connect the MCP server](https://gelatinui.com/docs/mcp-server.md): ask your agent for a theme from your brand color, font, and radius.
