# Colors (https://divplate.com/docs/colors)



Blocks only use the shadcn color variables from your `globals.css`, such as
`--background`, `--card` and `--primary`. So a block takes on your colors, and
installing one changes nothing you already have.

## Which variables to set [#which-variables-to-set]

No theme yet? Set `--background`, `--foreground`, `--primary`, `--muted`,
`--muted-foreground` and `--border`. The rest follows from those.

<Callout title="Stick to the variables">
  A fixed color like `bg-zinc-900` does not change with the theme, so it looks
  wrong in dark mode. Use `bg-background`, `text-muted-foreground` and so on.
</Callout>

## Buttons [#buttons]

Buttons use `--cta`, which is `--primary` unless you change it. Set `--cta` to
give your buttons a different color.

<Callout title="Bright button colors">
  `--cta-rim-top` and `--cta-rim-bottom` are tuned for a near-black button. With
  a bright one, lower them to about `0.03` and `0.075`.
</Callout>

## Matching the previews [#matching-the-previews]

To get exactly the colors from the previews, add the theme:

```bash
npx shadcn@4.21.4 add @divplate/theme
```

It replaces your shadcn color variables, light and dark, sets `--radius` to
`1rem` and sets `--font-sans` to Geist. See [Corners](https://divplate.com/docs/layout#corners) and
[Typography](https://divplate.com/docs/typography).

It recolors every shadcn component you already have, not just ours.

## Light and dark [#light-and-dark]

A section follows your site's theme. Use `scheme` to keep it one way:

| Value   | What it does                      |
| ------- | --------------------------------- |
| `auto`  | Follows the theme toggle          |
| `light` | Always light, even on a dark page |
| `dark`  | Always dark, even on a light page |

```tsx
<Footer01 section={{ scheme: "dark" }} />
```

## Palettes [#palettes]

A palette is another set of colors for the same blocks. The picker on the
previews switches between nine of them, and each one installs on its own:

```bash
npx shadcn@4.21.4 add @divplate/palette-blue
```

The nine are `palette-purple`, `palette-blue`, `palette-turquoise`,
`palette-green`, `palette-yellow`, `palette-brown`, `palette-orange`,
`palette-red` and `palette-pink`.

Turn one on with an attribute. Put it on `<html>` for the whole site, or on a
single element:

```html
<section data-palette="blue">…</section>
```

Everything inside follows it, in light and dark, buttons included.

### Making your own [#making-your-own]

Only override what your palette changes:

```css title="app/globals.css"
[data-palette="lime"] {
  --background: oklch(0.994 0.003 130);
  --foreground: oklch(0.18 0.012 135);
  --muted: oklch(0.965 0.006 130);
  --border: oklch(0.915 0.008 130);
  --primary: oklch(0.68 0.17 130);
  --primary-foreground: oklch(0.99 0 0);
  --ring: oklch(0.68 0.17 130);
  --cta: oklch(0.68 0.17 130);
  --cta-foreground: oklch(0.995 0 0);
}

.dark[data-palette="lime"],
[data-palette="lime"] .dark,
.dark [data-palette="lime"] {
  --background: oklch(0.168 0.004 135);
  --foreground: oklch(0.97 0.005 130);
  --muted: oklch(0.28 0.014 135);
  --border: oklch(1 0 0 / 12%);
}
```

Keep all three dark selectors. Without the middle one, a palette on `<html>`
stops working inside a section set to dark.

<Callout title="Some values are relative">
  A few tokens are set relative to another one. `--surface`, for example, is
  the page background plus a small step. Copy its number into a palette with a
  lighter background and the secondary button loses its top edge.
</Callout>

Name your palette after its color, like `lime`. That is the word people and
agents will guess first.
