# Theming (https://s3.dimah.dev/docs/ui/theming)

The components follow your shadcn theme out of the box, dark mode included.
To change their colors without changing your app, set `--dimah-s3-*` tokens.

## Override a token [#override-a-token]

Set tokens after the stylesheet import, on `:root`:

```css title="app/globals.css"
@import "@dimah-s3/ui/styles.css";

:root {
  --dimah-s3-primary: oklch(0.65 0.15 150); /* [!code ++] */
  --dimah-s3-destructive: oklch(0.55 0.2 25); /* [!code ++] */
}

.dark {
  --dimah-s3-primary: oklch(0.75 0.14 150); /* [!code ++] */
}
```

Or on any container, to style one area differently:

```css
.avatar-panel {
  --dimah-s3-primary: oklch(0.6 0.14 250);
  --dimah-s3-card: var(--muted);
}
```

Each token is read where it is used, so an override on a container reaches
every component inside it, including under a nested `.dark` class.

## Tokens [#tokens]

Every token is unset by default and falls back to the matching shadcn
variable.

| Token                         | Falls back to              |
| ----------------------------- | -------------------------- |
| `--dimah-s3-background`       | `--background`             |
| `--dimah-s3-foreground`       | `--foreground`             |
| `--dimah-s3-card`             | `--card`                   |
| `--dimah-s3-card-foreground`  | `--card-foreground`        |
| `--dimah-s3-primary`          | `--primary`                |
| `--dimah-s3-muted`            | `--muted`                  |
| `--dimah-s3-muted-foreground` | `--muted-foreground`       |
| `--dimah-s3-border`           | `--border`                 |
| `--dimah-s3-ring`             | `--ring`                   |
| `--dimah-s3-destructive`      | `--destructive`            |
| `--dimah-s3-success`          | `--success`, else a green  |
| `--dimah-s3-warning`          | `--warning`, else an amber |

shadcn has no `--success` or `--warning`. When your theme defines them, the
components use them; otherwise they use `--dimah-s3-success-default` and
`--dimah-s3-warning-default`, which the stylesheet sets for light and dark.

## What the tokens cover [#what-the-tokens-cover]

The tokens color the dimah-s3 parts: cards, rings, glyphs, meters, and status
colors. The shadcn primitives inside them (buttons, menus, dialogs, tooltips,
and toasts) keep reading your shadcn variables, such as `--primary`,
`--accent`, and `--popover`, so they match the rest of your app.

## Use the tokens in your own parts [#use-the-tokens-in-your-own-parts]

Each token has a Tailwind utility: `bg-dimah-s3-card`,
`text-dimah-s3-primary`, `border-dimah-s3-border`, and so on. Use them in parts
of your own so they follow the same overrides.

## Frequently asked questions [#frequently-asked-questions]

<Accordions>
<Accordion title="I set --color-dimah-s3-primary and nothing changed.">
Set `--dimah-s3-primary` instead. The `--color-dimah-s3-*` variables are the
Tailwind mappings, and they read the `--dimah-s3-*` tokens.
</Accordion>

<Accordion title="Do the tokens work with the shadcn registry?">
Yes. `shadcn add` writes the same color mappings and defaults into your CSS, so
the copied components read the same `--dimah-s3-*` tokens.
</Accordion>
</Accordions>