For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /dolan/theming.md.

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

src/styles/default.css
page {
  --primary: rgba(24, 24, 27, 1);
  --primary-foreground: rgba(250, 250, 250, 1);
}
<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), 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 for the other color rules.

Opacity modifiers

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

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 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 reads the glass-* colors. dolan update adds them if you never edited the theme. If you did, dolan 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 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 lists the missing twins with the line to add.

Tokens

TokenTailwind classesUsed for
background / foregroundbg-background, text-foregroundThe app background and its text
card / card-foregroundbg-card, text-card-foregroundCards and raised surfaces
primary / primary-foregroundbg-primary, text-primary-foregroundMain buttons, checked controls, your brand color
secondary / secondary-foregroundbg-secondary, text-secondary-foregroundSecondary buttons, button groups
muted / muted-foregroundbg-muted, text-muted-foregroundField backgrounds, tab bars, helper text
accent / accent-foregroundbg-accent, text-accent-foregroundPressed toggles, the nav drawer's current item
destructive / destructive-foregroundbg-destructive, text-destructive-foregroundDelete buttons, errors
destructive-subtlebg-destructive-subtleThe destructive alert's background
borderborder-borderBorders and separators
inputborder-input, bg-inputThe switch's off track
ringborder-ringInput and textarea focus rings
ring-subtlenoneThe soft outer focus ring, set inline by fields
chart-1 … chart-5bg-chart-1 … bg-chart-5Chart series colors, legend swatches
glass-foreground, glass-muted-foregroundtext-glass-foreground, text-glass-muted-foregroundText and icons on Glass
glass-clear-foregroundtext-glass-clear-foregroundText on clear glass, white in both themes
glass-tint / glass-tint-foregroundbg-glass-tint, text-glass-tint-foregroundTinted glass, and what sits on it
glass-dimbg-glass-dimThe dimming layer under clear glass

Every color class works with bg-, text- and border-, and takes 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:

ClassValueDefaultUsed for
rounded-smcalc(var(--radius) - 4px)8pxTabs inside their bar
rounded-mdcalc(var(--radius) - 2px)10pxSmall buttons
rounded-lgvar(--radius)12pxButtons, fields
rounded-xlcalc(var(--radius) + 4px)16pxCards, alerts, toasts
rounded-2xlcalc(var(--radius) + 8px)20pxDialogs, sheets
rounded-3xlcalc(var(--radius) + 12px)24pxYour own surfaces

Sizes

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, and every field (Input, Select, Date Picker). 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.

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.

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) and provideIconTheme() (see Icon). The icon copy also colors Spinner and Pagination's arrows.
  • dolan 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):

src/styles/default.css
page {
  --success: rgba(22, 163, 74, 1);
  --success-rgb: 22, 163, 74;
}
src/styles/tailwind-plugin.ts
const colors = {
  // …the existing colors…
  success: themeColor('success'),
};

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

src/styles/tailwind.css
@theme inline {
  /* …the existing colors… */
  --color-success: var(--success); 
}

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

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

src/styles.css
@import './styles/default.css';
@import './styles/dark.css'; 

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

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.

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:

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'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.

VariableLight (default.css)Dark (dark.css)
--backgroundrgba(255, 255, 255, 1)rgba(9, 9, 11, 1)
--foregroundrgba(9, 9, 11, 1)rgba(250, 250, 250, 1)
--cardrgba(255, 255, 255, 1)rgba(24, 24, 27, 1)
--card-foregroundrgba(9, 9, 11, 1)rgba(250, 250, 250, 1)
--primaryrgba(24, 24, 27, 1)rgba(250, 250, 250, 1)
--primary-foregroundrgba(250, 250, 250, 1)rgba(24, 24, 27, 1)
--secondaryrgba(244, 244, 245, 1)rgba(39, 39, 42, 1)
--secondary-foregroundrgba(24, 24, 27, 1)rgba(250, 250, 250, 1)
--mutedrgba(244, 244, 245, 1)rgba(39, 39, 42, 1)
--muted-foregroundrgba(113, 113, 122, 1)rgba(161, 161, 170, 1)
--accentrgba(244, 244, 245, 1)rgba(39, 39, 42, 1)
--accent-foregroundrgba(24, 24, 27, 1)rgba(250, 250, 250, 1)
--destructivergba(220, 38, 38, 1)rgba(248, 113, 113, 1)
--destructive-foregroundrgba(250, 250, 250, 1)rgba(24, 24, 27, 1)
--destructive-subtlergba(220, 38, 38, 0.08)rgba(248, 113, 113, 0.14)
--borderrgba(228, 228, 231, 1)rgba(52, 52, 56, 1)
--inputrgba(228, 228, 231, 1)rgba(39, 39, 42, 1)
--ringrgba(24, 24, 27, 1)rgba(212, 212, 216, 1)
--ring-subtlergba(24, 24, 27, 0.4)rgba(212, 212, 216, 0.4)
--chart-1rgba(231, 110, 80, 1)rgba(38, 98, 217, 1)
--chart-2rgba(42, 157, 144, 1)rgba(46, 184, 138, 1)
--chart-3rgba(39, 71, 84, 1)rgba(232, 140, 48, 1)
--chart-4rgba(232, 196, 104, 1)rgba(175, 87, 219, 1)
--chart-5rgba(244, 164, 98, 1)rgba(226, 54, 112, 1)
--glass-tintrgba(24, 24, 27, 1)rgba(250, 250, 250, 1)
--glass-tint-foregroundrgba(250, 250, 250, 1)rgba(24, 24, 27, 1)
--glass-foregroundrgba(9, 9, 11, 1)rgba(250, 250, 250, 1)
--glass-muted-foregroundrgba(63, 63, 70, 1)rgba(212, 212, 216, 1)
--glass-clear-foregroundrgba(255, 255, 255, 1)rgba(255, 255, 255, 1)
--glass-dimrgba(0, 0, 0, 0.35)rgba(0, 0, 0, 0.35)
--radius12px12px