> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Theming

Change the look of every UI component by editing one CSS file. Components take their colors from **theme tokens**: CSS variables such as `--primary` whose values you set.

## How it works

```css title="src/styles/default.css"
page {
  --primary: rgba(24, 24, 27, 1);
  --primary-foreground: rgba(250, 250, 250, 1);
}
```

```angular-html
<view class="bg-primary p-4">
  <text class="text-primary-foreground">Saved</text>
</view>
```

- The tokens are set on `page`, the root element of every Lynx app (see [Glossary](/guide/glossary.md#page)), so every element can read them.
- Each token holds a complete `rgba()` color. `tailwind.css` (or, on Tailwind 3, `tailwind-plugin.ts`) maps the classes straight to the variable: `bg-primary` becomes `background-color: var(--primary)`.
- `dolan init` copied both files into `src/styles/`. They're yours to edit.

The tokens are complete colors because of how Lynx parses them. Lynx accepts only comma-separated `hsl()`, while the usual shadcn/ui setup produces space-separated `hsl(var(--x) / 1)`. Lynx drops that value without a warning, and the element renders transparent. See [CSS on Lynx](/guide/styling/index.md) for the other color rules.

## Opacity modifiers

```angular-html
<view class="bg-primary/50 border border-border/60">
  <text class="text-foreground/70">Draft</text>
</view>
```

Every color class takes Tailwind's opacity modifiers: `bg-primary/50`, `text-foreground/70`, `border-border/60`, `bg-destructive/10`. They follow dark mode like the plain classes.

A modifier needs the color's red, green and blue on their own, so each token has a twin ending in `-rgb`:

```css title="src/styles/default.css"
page {
  --primary: rgba(24, 24, 27, 1);
  --primary-rgb: 24, 24, 27;
}
```

- `bg-primary` reads `--primary`: `background-color: var(--primary)`.
- `bg-primary/50` reads `--primary-rgb`: `background-color: rgba(var(--primary-rgb), 0.5)`. Tailwind 4 writes the modifier as `color-mix()`, which Lynx can't read, and the build turns it into the same `rgba()`.
- **Keep each pair the same color.** If you change `--primary`, change `--primary-rgb` too. [`dolan doctor`](/dolan/cli/index.md#doctor) warns when a pair doesn't match.
- **Write the channels with commas.** Lynx fills `rgba()` with the variable's text before it reads the color, so `24, 24, 27` becomes three arguments.

`--destructive-subtle` (a faint red) and `--glass-dim` (black at 35%) are already translucent, so they have no twin and take no modifier.

### Themes from before a component's colors

Some components read colors the theme gained after you may have copied it: [Glass](/dolan/glass.md) reads the `glass-*` colors. `dolan update` adds them if you never edited the theme. If you did, [`dolan doctor`](/dolan/cli/index.md#doctor) lists the variables your theme lacks, with the lines to add, and the colors your `tailwind.css` or plugin doesn't map.

### Themes from before opacity modifiers

Themes copied by an older dolan have no `-rgb` variables. [`dolan update`](/dolan/cli/updates.md#update) brings them in if you never edited the theme, and keeps your files if you did. Without the twins, the plain classes still work, and a modifier draws nothing. [`dolan doctor`](/dolan/cli/index.md#doctor) lists the missing twins with the line to add.

## Tokens

| Token                                        | Tailwind classes                                       | Used for                                         |
| -------------------------------------------- | ------------------------------------------------------ | ------------------------------------------------ |
| `background` / `foreground`                  | `bg-background`, `text-foreground`                     | The app background and its text                  |
| `card` / `card-foreground`                   | `bg-card`, `text-card-foreground`                      | Cards and raised surfaces                        |
| `primary` / `primary-foreground`             | `bg-primary`, `text-primary-foreground`                | Main buttons, checked controls, your brand color |
| `secondary` / `secondary-foreground`         | `bg-secondary`, `text-secondary-foreground`            | Secondary buttons, button groups                 |
| `muted` / `muted-foreground`                 | `bg-muted`, `text-muted-foreground`                    | Field backgrounds, tab bars, helper text         |
| `accent` / `accent-foreground`               | `bg-accent`, `text-accent-foreground`                  | Pressed toggles, the nav drawer's current item   |
| `destructive` / `destructive-foreground`     | `bg-destructive`, `text-destructive-foreground`        | Delete buttons, errors                           |
| `destructive-subtle`                         | `bg-destructive-subtle`                                | The destructive alert's background               |
| `border`                                     | `border-border`                                        | Borders and separators                           |
| `input`                                      | `border-input`, `bg-input`                             | The switch's off track                           |
| `ring`                                       | `border-ring`                                          | Input and textarea focus rings                   |
| `ring-subtle`                                | none                                                   | The soft outer focus ring, set inline by fields  |
| `chart-1` … `chart-5`                        | `bg-chart-1` … `bg-chart-5`                            | Chart series colors, legend swatches             |
| `glass-foreground`, `glass-muted-foreground` | `text-glass-foreground`, `text-glass-muted-foreground` | Text and icons on [Glass](/dolan/glass.md)       |
| `glass-clear-foreground`                     | `text-glass-clear-foreground`                          | Text on clear glass, white in both themes        |
| `glass-tint` / `glass-tint-foreground`       | `bg-glass-tint`, `text-glass-tint-foreground`          | Tinted glass, and what sits on it                |
| `glass-dim`                                  | `bg-glass-dim`                                         | The dimming layer under clear glass              |

Every color class works with `bg-`, `text-` and `border-`, and takes [opacity modifiers](#opacity-modifiers) such as `bg-primary/50`. The theme also gives `border-color: var(--border)` to Tailwind's border-width classes, so a plain `border` class draws in the theme's border color. Lynx's own default is black.

With Tailwind 3, the plugin gives it to every border-width class the app uses, prefixed and arbitrary ones too (`dark:border`, `border-[1.5px]`). It turns on Tailwind 3's `optimizeUniversalDefaults` for that, so the build prints Tailwind's notice about an experimental feature. If your `tailwind.config.ts` sets `experimental` itself, add `optimizeUniversalDefaults: true` to it: your object replaces the plugin's, and without the flag every element gets the color.

With Tailwind 4, `tailwind.css` gives it to the unprefixed border-width classes: `border` and each side (`border-t`, `border-x`, …), plain or at `-2`, `-4` and `-8`. These need a color class of their own:

- **Other widths:** `border-3`, `border-[1.5px]`. Add `border-border`.
- **Prefixed widths:** `dark:border`, `sm:border-t`. Add the same prefix: `dark:border dark:border-border`.
- **Dividers:** `divide-y` borders the children. Add `divide-border`.

Neither uses shadcn/ui's `* { border-color: var(--border) }`: on iOS, Lynx keeps four colors for each element with a border color, about 1.3 KB of native memory each, whether it has a border or not.

### Radius

`--radius` (default `12px`) is the corner of a control: a button, a field. Every rounded class steps from it, so one value makes the whole app rounder or squarer:

| Class         | Value                        | Default | Used for              |
| ------------- | ---------------------------- | ------- | --------------------- |
| `rounded-sm`  | `calc(var(--radius) - 4px)`  | 8px     | Tabs inside their bar |
| `rounded-md`  | `calc(var(--radius) - 2px)`  | 10px    | Small buttons         |
| `rounded-lg`  | `var(--radius)`              | 12px    | Buttons, fields       |
| `rounded-xl`  | `calc(var(--radius) + 4px)`  | 16px    | Cards, alerts, toasts |
| `rounded-2xl` | `calc(var(--radius) + 8px)`  | 20px    | Dialogs, sheets       |
| `rounded-3xl` | `calc(var(--radius) + 12px)` | 24px    | Your own surfaces     |

### Sizes

```css title="src/styles/default.css"
page {
  font-size: 16px;
  --rem-unit: 16px;
}
```

- **`1rem` is 16px, as in a browser.** Lynx's own root font size is 14px. So every Tailwind size came out an eighth smaller on a phone than in the web preview: a 48px button was 42px. With the theme, `h-12` is 48px everywhere.
- **The components are sized in `rem`.** Raise `font-size` (and `--rem-unit` with it) and they grow with the text.
- **Controls are 48px tall**: a default [Button](/dolan/button.md), and every field ([Input](/dolan/input.md), [Select](/dolan/select.md), [Date Picker](/dolan/date-picker.md)). That's Android's 48dp touch target, which covers iOS's 44pt, and a button beside a field lines up with it.
- **Text is 16px**, a phone's body size: `text-base`. Use `text-sm` (14px) for secondary text.

### Page background and text color

`default.css` also gives `page` the theme's background, and gives text the theme's foreground color:

- **A screen with no background of its own is `bg-background`**, in both appearances.
- **A `<text>` with no color class is `text-foreground`.** Lynx draws text black otherwise, which vanishes in the dark. A `<text>` inside another `<text>` keeps its parent's color.

### Safe area

The plugin also adds padding classes that keep content clear of the notch and home indicator: `pt-safe`, `pb-safe`, `px-safe`, `p-safe` and the others. The numbered forms add a spacing value on top, so `pb-safe-4` is `calc(1rem + env(safe-area-inset-bottom))`. See [Safe area](/guide/safe-area.md).

## Customize your brand

Edit the values in `default.css`. Write each one as a complete `rgba()` or hex color, and its `-rgb` twin as the same color's channels.

```css title="src/styles/default.css"
page {
  --primary: rgba(37, 99, 235, 1);
  --primary-rgb: 37, 99, 235;
  --primary-foreground: rgba(255, 255, 255, 1);
  --primary-foreground-rgb: 255, 255, 255;
  --ring: rgba(37, 99, 235, 1);
  --ring-rgb: 37, 99, 235;
  --ring-subtle: rgba(37, 99, 235, 0.4);
  --radius: 16px;
  /* …keep the other tokens… */
}
```

- Change the same tokens in `dark.css`.
- Charts and icons draw with a TypeScript copy of these colors, because Lynx's SVG renderer can't read CSS variables. Pass your new values to `provideChartTheme()` (see [Chart](/dolan/chart.md)) and `provideIconTheme()` (see [Icon](/dolan/icon.md#dark-mode)). The icon copy also colors Spinner and Pagination's arrows.
- [`dolan update`](/dolan/cli/updates.md#update) merges theme changes too, so your edits survive updates.

### Add a token

Add the variable and its channels to both theme files, then map it in the plugin with `themeColor()` (Tailwind 3) or in `tailwind.css` (Tailwind 4):

```css title="src/styles/default.css"
page {
  --success: rgba(22, 163, 74, 1);
  --success-rgb: 22, 163, 74;
}
```

```typescript title="src/styles/tailwind-plugin.ts"
const colors = {
  // …the existing colors…
  success: themeColor('success'), // [!code highlight]
};
```

On Tailwind 4, map it in `tailwind.css` instead:

```css title="src/styles/tailwind.css"
@theme inline {
  /* …the existing colors… */
  --color-success: var(--success); /* [!code highlight] */
}
```

You can now use `bg-success`, `text-success` and `bg-success/10`. Without the `-rgb` line, the modifiers draw nothing. A color you only ever use whole can skip it and map to the variable instead: `success: 'var(--success)'`.

### Start a new theme

```bash
npx @blotch/dolan theme ocean
```

This copies `default.css` to `src/styles/ocean.css`. Edit it, then import it in place of `default.css` in `src/styles.css`. `dolan update` doesn't merge themes you create this way.

## Dark mode

```css title="src/styles.css"
@import './styles/default.css';
@import './styles/dark.css'; /* [!code highlight] */
```

Import `dark.css` after `default.css` and the app follows the phone: light in light mode, dark in dark mode, with no code.

- **`dark.css` has a dark value for every token, under `page.dark`.** AngularLynx gives `page` the `dark` class while the phone is dark, and takes it away when it isn't.
- **Icons and charts follow too.** They draw with a TypeScript copy of the colors, and pick the light or the dark table from the same appearance.
- **In the web preview it follows the browser's** `prefers-color-scheme`.

### Let the user choose

```typescript
import { inject } from '@angular/core';
import { LynxTheme } from '@blotch/angular-lynx';

const theme = inject(LynxTheme);
theme.setColorScheme('dark'); // 'system', 'light' or 'dark'
```

`setColorScheme()` draws the app light or dark whatever the phone says, and `'system'` follows the phone again. See [Dark mode](/guide/dark-mode.md#let-the-user-choose).

### Stay light

Leave `dark.css` out, and tell AngularLynx the app is always light, so icons and charts don't switch to their dark colors on a dark phone:

```typescript title="src/app/app.config.ts"
import { provideColorScheme } from '@blotch/angular-lynx';

providers: [provideColorScheme('light')];
```

### Dark surfaces

In the dark, a raised surface is a tone lighter than the page, as iOS and Android draw theirs: `--card` is lighter than `--background`. Cards, dialogs, sheets and toasts are on `bg-card`, so they stand out without a shadow. Use `bg-card` for your own raised surfaces.

## Wallpaper colors on Android

On Android 12 and later, the theme can take the colors of the user's wallpaper, as Material You apps do. Add [Dynamic Color](/dolan/dynamic-color.md)'s `uiDynamicColor` to your root view. It sets the tokens above to the wallpaper's colors, so there's no second set of colors to keep.

## Variable reference

Generated from `default.css` and `dark.css`. Each opaque color also has a `-rgb` twin with its channels, such as `--primary-rgb: 24, 24, 27`, left out here.

| Variable                   | Light (`default.css`)     | Dark (`dark.css`)           |
| -------------------------- | ------------------------- | --------------------------- |
| `--background`             | `rgba(255, 255, 255, 1)`  | `rgba(9, 9, 11, 1)`         |
| `--foreground`             | `rgba(9, 9, 11, 1)`       | `rgba(250, 250, 250, 1)`    |
| `--card`                   | `rgba(255, 255, 255, 1)`  | `rgba(24, 24, 27, 1)`       |
| `--card-foreground`        | `rgba(9, 9, 11, 1)`       | `rgba(250, 250, 250, 1)`    |
| `--primary`                | `rgba(24, 24, 27, 1)`     | `rgba(250, 250, 250, 1)`    |
| `--primary-foreground`     | `rgba(250, 250, 250, 1)`  | `rgba(24, 24, 27, 1)`       |
| `--secondary`              | `rgba(244, 244, 245, 1)`  | `rgba(39, 39, 42, 1)`       |
| `--secondary-foreground`   | `rgba(24, 24, 27, 1)`     | `rgba(250, 250, 250, 1)`    |
| `--muted`                  | `rgba(244, 244, 245, 1)`  | `rgba(39, 39, 42, 1)`       |
| `--muted-foreground`       | `rgba(113, 113, 122, 1)`  | `rgba(161, 161, 170, 1)`    |
| `--accent`                 | `rgba(244, 244, 245, 1)`  | `rgba(39, 39, 42, 1)`       |
| `--accent-foreground`      | `rgba(24, 24, 27, 1)`     | `rgba(250, 250, 250, 1)`    |
| `--destructive`            | `rgba(220, 38, 38, 1)`    | `rgba(248, 113, 113, 1)`    |
| `--destructive-foreground` | `rgba(250, 250, 250, 1)`  | `rgba(24, 24, 27, 1)`       |
| `--destructive-subtle`     | `rgba(220, 38, 38, 0.08)` | `rgba(248, 113, 113, 0.14)` |
| `--border`                 | `rgba(228, 228, 231, 1)`  | `rgba(52, 52, 56, 1)`       |
| `--input`                  | `rgba(228, 228, 231, 1)`  | `rgba(39, 39, 42, 1)`       |
| `--ring`                   | `rgba(24, 24, 27, 1)`     | `rgba(212, 212, 216, 1)`    |
| `--ring-subtle`            | `rgba(24, 24, 27, 0.4)`   | `rgba(212, 212, 216, 0.4)`  |
| `--chart-1`                | `rgba(231, 110, 80, 1)`   | `rgba(38, 98, 217, 1)`      |
| `--chart-2`                | `rgba(42, 157, 144, 1)`   | `rgba(46, 184, 138, 1)`     |
| `--chart-3`                | `rgba(39, 71, 84, 1)`     | `rgba(232, 140, 48, 1)`     |
| `--chart-4`                | `rgba(232, 196, 104, 1)`  | `rgba(175, 87, 219, 1)`     |
| `--chart-5`                | `rgba(244, 164, 98, 1)`   | `rgba(226, 54, 112, 1)`     |
| `--glass-tint`             | `rgba(24, 24, 27, 1)`     | `rgba(250, 250, 250, 1)`    |
| `--glass-tint-foreground`  | `rgba(250, 250, 250, 1)`  | `rgba(24, 24, 27, 1)`       |
| `--glass-foreground`       | `rgba(9, 9, 11, 1)`       | `rgba(250, 250, 250, 1)`    |
| `--glass-muted-foreground` | `rgba(63, 63, 70, 1)`     | `rgba(212, 212, 216, 1)`    |
| `--glass-clear-foreground` | `rgba(255, 255, 255, 1)`  | `rgba(255, 255, 255, 1)`    |
| `--glass-dim`              | `rgba(0, 0, 0, 0.35)`     | `rgba(0, 0, 0, 0.35)`       |
| `--radius`                 | `12px`                    | `12px`                      |

## Related

- [UI Components](/dolan/index.md): install the theme with `dolan init`
- [CSS on Lynx](/guide/styling/index.md): color formats and other CSS differences
- [Tailwind CSS](/guide/tailwindcss.md): the Tailwind setup the theme builds on
- [Dark mode](/guide/dark-mode.md): switching themes at runtime
- [Dynamic Color](/dolan/dynamic-color.md): the wallpaper's colors on Android
