# Theming

> Change the look of the UI components: tokens, parts and states, classes per part, slots, Tailwind.

The elements draw no colour, corner or font of their own: they read [tokens](https://docs.altasystem.ai/ui/tokens) (`--aui-*` custom
properties). Their CSS sits in the layers `aui.tokens`, `aui.base`, `aui.motion`, `aui.theme`, with selectors inside
`:where()`: any CSS of yours, outside these layers, wins with one class.

## The files

| Import | What it gives |
|---|---|
| `@altasystem/ui/styles.css` | the tokens with neutral values, the structure of every element, the motion |
| `@altasystem/ui/themes/galaxy.css` | the game's look: dark, warm accent, round corners, Hanken Grotesk |
| `@altasystem/ui/themes/alta.css` | Alta's look, light and dark (`scheme="light"`, `"dark"` or `"auto"`) |
| nothing | unstyled: the elements still render their parts, states, focus and ARIA |

A theme applies inside `<alta-provider theme="…">` (or any element with `data-aui-theme`).

## Four levels, from the lightest

**1. Tokens.** Most pages stop here.

```css
alta-provider { --aui-color-accent: #6d28d9; --aui-radius-md: 4px; }
```

Set a token where the theme is set (on the provider, or `[data-aui-theme]`): a token that reads another is computed
where it is declared.

**2. Parts and states.** Every element writes `data-aui` (its name), `data-state` (a closed list) and `data-part` on
each node: the [reference](https://docs.altasystem.ai/ui/components/) lists them all.

```css
[data-aui="run-progress"][data-state="failed"] [data-part="line"] { font-weight: 600; }
```

**3. Classes per part**, for utility-first projects: `configure({ classes })` for the page, or the `classes`
property of a provider. The classes are added to the part on every render.

```js
configure({ classes: { "plan-card": { root: "border border-black", action: "bg-black text-white px-4 py-2" } } });
```

**4. Slots.** A child with `slot="…"` replaces a place of the element (the plan card's `actions`, for instance) without
copying it.

## Tailwind

- v4: `@import "@altasystem/ui/tailwind.css";` declares the layer order, maps the tokens (`bg-aui-accent`,
  `rounded-aui-md`, `duration-aui-base`, `font-aui-display`) and adds a variant per state and part
  (`aui-running:opacity-80`, `aui-part-action:rounded-none`).
- v3: `presets: [require("@altasystem/ui/tailwind-preset.cjs")]` gives the same names.

```html
<alta-plan-card class="aui-planned:ring-2 aui-part-action:rounded-none"></alta-plan-card>
```

## Motion

Motion follows `prefers-reduced-motion`. `motion="off"` on a provider stops it for everything inside.
