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
cssintheme.phpbecome one bundle. Theirurl(...)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-primaryand the other--c-<key>variables. With dark mode on, they holdlight-dark()values.html[data-scheme]says which one shows. - Two versions of an image get
.lb-on-lightand.lb-on-dark. - Some designs draw dark mode with a class of their own. Such a design sets
dark_classintheme.php. The class then goes on<html>before the stylesheet.--c-<key>-lightand--c-<key>-darkcome along for its rules. - Visitor preferences, such as high contrast, reduced motion and save data, are
prefsintheme.php. Each one is a class on<html>.
Shape, space and text
- Tokens are in
:rooton every page:--radius-card,--radius-button,--radius-input,--border-width,--space,--section-space,--shadowand--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-priceand.lb-statuse--font-numericand--numeric-variant. Price and number fields come as<span class="lb-num">. - Focus points. An image gets
--focus, and also--focus-smand--focus-lg. The base components use them forobject-position, withobject-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.
Icons
- Icons that people chose are in
site.icon_set. Always draw them throughView::setIcon, never as the SVG text that comes in. It rebuilds the icon from its shapes, incurrentColor. Size and colour are CSS, on.lb-icon. The icons are decoration beside words, so they arearia-hidden. - Social services.
View::socialIcon($id)takesicons/social/<id>.svgof 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