# Styles, colours and icons

Use the CSS variables and classes that the CMS sends. Then a site owner can change colours, fonts, shape and space in **Theme**, without a new theme version.

## The CSS

- The files under `css` in `theme.php` become one bundle. Their `url(...)` points to the published files. On a first visit, the bundle is inline in the page. After that, it is a link.
- Every published file has its content in its address. So it is cached for a year, and never needs emptying.

## Colours and dark mode

- Use `--c-bg`, `--c-text`, `--c-primary`, `--c-on-primary` and the other `--c-<key>` variables. With dark mode on, they hold `light-dark()` values. `html[data-scheme]` says which one shows.
- Two versions of an image get `.lb-on-light` and `.lb-on-dark`.
- Some designs draw dark mode with a class of their own. Such a design sets `dark_class` in `theme.php`. The class then goes on `<html>` before the stylesheet. `--c-<key>-light` and `--c-<key>-dark` come along for its rules.
- Visitor preferences, such as high contrast, reduced motion and save data, are `prefs` in `theme.php`. Each one is a class on `<html>`.

## Shape, space and text

- **Tokens** are in `:root` on every page: `--radius-card`, `--radius-button`, `--radius-input`, `--border-width`, `--space`, `--section-space`, `--shadow` and `--border-colour`. Use them instead of fixed values.
- **Text styles** that people pick in the editor come as one stylesheet, after the CSS of the theme. `text-<colour>`, `alert-<colour>` and the square label are in the base components. They are made from `--c-<colour>`.
- **Numbers.** `.lb-num`, `.lb-price` and `.lb-stat` use `--font-numeric` and `--numeric-variant`. Price and number fields come as `<span class="lb-num">`.
- **Focus points.** An image gets `--focus`, and also `--focus-sm` and `--focus-lg`. The base components use them for `object-position`, with `object-fit: cover`.

## Classes from the CMS

Editors add classes to menu items, sections, rows and pages. Where the CMS can send classes, never write a class attribute by hand. Use `View::classAttr($themeDefaults, Classes::slot($node, 'slot'))` instead.

It merges what the editor typed into the defaults of the theme. It only replaces defaults of the same group. So `bg-dark` replaces `bg-light`, and `btn-lg` keeps `btn-primary`. Offer common choices as `presets` in the [package](/md/docs/themes/packages/).

## Icons

- **Icons that people chose** are in `site.icon_set`. Always draw them through `View::setIcon`, never as the SVG text that comes in. It rebuilds the icon from its shapes, in `currentColor`. Size and colour are CSS, on `.lb-icon`. The icons are decoration beside words, so they are `aria-hidden`.
- **Social services.** `View::socialIcon($id)` takes `icons/social/<id>.svg` of the theme first. Otherwise, it takes the icon of the CMS.
- **Flags.** Use `View::flagImg`. Always put the language or currency beside it, written out.

*Also called: theming, CSS variables, design tokens, dark theme, icon set.*

Last changed 26 November 2026
