SkillThe rules every piece follows

Theme

How a brand becomes a theme. Base and role tokens, brand colour roles, how OKLCH colours are made, status colours, colour recipes inside a piece, shadows, links, type and the brand image slots.

12 min readtheme.md

A theme restyles every piece at once: colours, fonts, buttons, inputs, cards, highlights and images. The theme is the controller. A piece keeps its layout, copy, scale and direct-response anatomy, and takes every colour, face and main-element style from the tokens. Switch the theme and the whole page changes, with contrast intact and nothing overflowing.

Applying a theme#

  1. Get the tokens. Turn the brand into a complete token set once. With FunnelDNA connected, brand_theme does this from a saved brand or from raw colours, fonts and images; the pack's presets.json and brands.json hold ready-made themes. You get OKLCH colour tokens, two font faces, image slot URLs and a note of any colour that was adjusted for contrast.
  2. Set the base tokens as CSS custom properties on :root or on the page's outermost wrapper.
  3. Set only the role tokens the theme changes, on the page wrapper (never :root). Leave the rest unset; each piece falls back to the base tokens at the point of use, so a section that sets --cta locally still reaches its own buttons.
  4. Load the two faces with every weight and italic the page uses.
  5. Pass brand images through the pieces' image props, by slot (see Images).

A funnel is light or dark, decided once from the brand and used on every page. No prefers-color-scheme switching and no toggle: a dark funnel is its own design, not a filter over the light one.

Base tokens#

The host always defines these.

Token Role
--surface Page background.
--card Solid card, panel and box background.
--ink, --muted Main and secondary text on surface and card.
--band, --band-ink A dark or strong band, and the text on it.
--cta, --cta-2, --cta-ink The action colour, its deeper partner, and the text on it.
--accent Second hue: icons, highlights of state.
--accent-fill, --accent-fill-ink The accent as the brand supplied it, for fills and decoration (stars, badges, ribbons, dots, rules), and the text on it. --accent is its text-safe version: a bright gold stays gold here and reads as a darker gold as text.
--link Text links in running copy.
--success Positive state: ticks, "added", saved, valid fields, savings.
--danger Negative state: errors, invalid fields, struck prices, "no" marks, removal.
--warning Attention: notices, real limited-time labels, the highlighter's base hue.
--success-soft, --danger-soft, --warning-soft Status backgrounds.
--field, --field-ink Input background and text.
--radius Base corner radius.
--font-display, --font-body Headline face and body face.
--shadow The shadow colour: always dark, tinted toward the band's hue.
--shadow-sm, --shadow-md, --shadow-lg Finished layered shadows for chips, cards and raised panels.
--secondary, --secondary-ink A quiet grey fill in the ink's hue, and the text on it.
--button-text-shadow A sharp 1px shade under light text on the primary button; none when the text is dark.
--marker The highlighter colour, derived from the warning hue and readable behind ink.
--bump, --bump-strip, --bump-ink Order bump colours: the classic direct-response yellow box (pale butter paper, a richer yellow checkbox strip, and text readable on both). On dark themes, a warm dark tint. Order bumps use these, never status tints or accent mixes.

Brand colour roles#

A brand can set any base colour by role. Anything left on Auto is derived.

Role Token Derived from it
Main button --cta --cta-2, --cta-ink, --button-text-shadow
Accent --accent --accent-fill, --accent-fill-ink
Link --link Defaults to the accent.
Page background --surface
Cards --card
Text --ink --secondary-ink
Secondary text --muted
Dark band --band --band-ink, --shadow
Success --success --success-soft
Error --danger --danger-soft
Highlight --warning --warning-soft, --marker

Ticks and crosses in a circle are solid badges: the circle filled with --success (tick) or --danger (cross) and the glyph in white. Never a soft tinted circle with a coloured glyph; the -soft tokens are for panels and messages.

Every text pair is kept at 4.5:1 (secondary text at 5:1). An explicit colour is only changed when it would fail, and only in lightness; the theme reports each change.

How the colours are made#

All theme colours are derived, adjusted and mixed in OKLCH (perceptual lightness L from 0 to 1, chroma C, hue H), never in sRGB. Tokens are emitted as oklch(L C H); contrast is checked with WCAG 2 ratios on the resulting sRGB colour.

  • Contrast fixes change L only. The hue stays and as much chroma as the gamut allows. A brand green stays green; nothing drifts to grey.
  • Light themes. Surface is the brand background, or L≈0.985 with the brand hue at C≤0.01. Card is white unless the brand sets one. Band is a deep brand hue (L≈0.22–0.30, C≤0.08). Ink is L≈0.18–0.22 with a whisper of the brand hue. Muted is ink moved toward the surface until it reaches 5:1.
  • Dark themes. Surface is the brand background, or L≈0.17–0.22. Card is the surface plus 0.04–0.07 L, same hue and chroma. Band is the surface plus 0.07–0.10 L, or a deep brand hue. Ink is L≈0.94–0.97; muted L≈0.75–0.80. Never mid-greys (L 0.45–0.65) for surfaces or cards.
  • Main button. The brand colour. --cta-2 is the same colour at L − 0.07. --cta-ink is white or near-black, whichever passes.
  • Accent. The brand's second colour, else the main hue, adjusted in L to 4.5:1 on card and surface. Never white or black.
  • Status. Success H≈150, danger H≈27, warning H≈85, with chroma as high as the gamut allows (about 0.13–0.17). L is chosen so status text reads at 4.5:1 on card, on surface and on its own soft background (about L 0.50 on light themes, 0.75 on dark). An explicit status colour keeps its hue.

Status colours#

Status colours are hues, not surfaces. Use them for icons, text, borders and small fills.

  • Status text on a status background is always the matching pair: --success on --success-soft, --danger on --danger-soft, --warning on --warning-soft.
  • Each soft token is a 14% tint of the status colour into the card that keeps the status hue (a warning tint stays amber on a navy card), resolved by the theme. Read the token; never mix your own status percentage in a piece.
  • The 4.5:1 guarantee covers card, surface and the matching soft background. It does not cover bands, images or text with reduced opacity.
  • Never use --accent or --cta to mean success or error.

Colour recipes inside a piece#

Derive every shade, tint, border, overlay and shadow from the tokens, so colours stay clear and in hue under any theme. Use CSS relative colour syntax and color-mix(in oklch, …).

Need Recipe
Hover oklch(from var(--cta) calc(l - 0.06) c h)
Pressed oklch(from var(--cta) calc(l - 0.10) c h)
Lighter edge oklch(from var(--cta) calc(l + 0.08) c h)
In-hue gradient (buttons, badges, small fills only) linear-gradient(oklch(from var(--cta) calc(l + 0.04) c h), oklch(from var(--cta) calc(l - 0.05) c h))
Quiet panel color-mix(in oklch, var(--ink) 4%, var(--card)) (3–7%; mix into --surface on the page), or var(--secondary) for a stronger grey
The one chosen thing color-mix(in oklch, var(--accent) 10%, var(--card)) (8–16%)
Border or divider oklch(from var(--ink) l c h / 0.14)
Overlay or scrim oklch(from var(--band) l c h / 0.6)
Inset highlight oklch(from var(--card) calc(l + 0.04) c h / 0.6)

The same recipes work for accent, band and the status colours.

  • Quiet panels are grey, not brand-tinted. Inactive tabs and steps, info, note and guarantee boxes, table and summary rows, chips and wells use the neutral ink tint. An accent tint there turns every quiet panel pink or orange when the accent is pink or orange.
  • A brand tint marks only the one chosen thing: the selected option, the active step, the featured card.
  • Never mix two different hues in OKLCH (--cta with --band, --accent with --cta). OKLCH interpolates around the hue wheel, so red and navy make magenta. A lighter or darker version of a colour is the same colour with L moved. A real blend of two hues uses color-mix(in oklab, …). Mixing a colour with a neutral (--card, --surface, --ink, white, black, transparent) in OKLCH is fine.
  • Never use gradients for section backgrounds.
  • Text on any derived background still reads at 4.5:1. Move L rather than lowering opacity.
  • No hard-coded colours and no rgba() or hex shades of a theme colour. The token plus a recipe is always the source.

Shadows#

Shadows are dark, sharp and close. No light glows, no fuzzy haze, no solid offsets.

  • Use var(--shadow-sm), var(--shadow-md) or var(--shadow-lg), or build on --shadow: 0 1px 2px oklch(from var(--shadow) l c h / 0.25).
  • Never build a shadow from a light or theme-flipping token (--surface, --card, --field, --ink, --band-ink, --cta-ink, white). On a dark theme those become white glows. Inset highlights such as inset 0 1px 0 oklch(from var(--cta) calc(l + 0.12) c h / 0.6) are not shadows and are fine.
  • Pair a tight contact layer (blur up to 3px) with a short ambient layer with negative spread (0 4px 10px -2px). No single big blur without a contact layer, no 0 0 Npx halos around cards.
  • No solid offset shadows (4px 4px 0, 0 6px 0). A button's bottom lip is an inset bevel: inset 0 -3px 0 oklch(from var(--cta) calc(l - 0.16) c h).
  • The fallback inside var() is a dark recipe too.

Role tokens#

Role tokens style the main elements. Each falls back to the base tokens, so always write the full fallback chain: var(--button-bg, var(--cta)).

Element Tokens (fallback)
Primary button --button-bg (--cta), --button-bg-2 (--cta-2, gradient end), --button-ink (--cta-ink), --button-radius (--radius), --button-font (--font-display), --button-weight (800), --button-case (none), --button-shadow (the piece's own shadow), and text-shadow: var(--button-text-shadow, none)
Secondary button --button-2-bg (--secondary), --button-2-ink (--secondary-ink), --button-2-border (transparent), --button-2-shadow (the primary's bevel in the secondary colour: inset 0 -2px 0 oklch(from var(--secondary) calc(l - 0.1) c h), var(--shadow-sm))
Input, select, textarea --field, --field-ink, --field-border (color-mix(in oklch, var(--ink) 22%, transparent)), --field-radius (--radius), --field-focus (--accent), --label-ink (--ink)
Card or panel --card, --card-border (color-mix(in oklch, var(--ink) 12%, transparent)), --card-radius (--radius), --card-shadow (the piece's own shadow)
Headline type --display-weight (800), --display-case (none), --display-tracking (the piece's own value)
Marker highlight --marker (a translucent yellow)
  • A piece may keep its own button or input markup; its design is the point. Its colours, radius, face, weight and shadow still come from these tokens.
  • The secondary button is a filled grey button in the primary's style (same radius, face, weight, case, bevel and size), quieter in colour. Never a second brand colour. A theme that wants an outline secondary sets --button-2-bg: transparent, a --button-2-border and --button-2-shadow: none; pieces never hard-code an outline.
  • Light text on the primary button always carries text-shadow: var(--button-text-shadow, none): one sharp 1px shade of the button colour, never a blur or a black glow.
  • Piece-specific details (a signature ink, a seal tint) are variables scoped to the piece with a token fallback: --signature-ink: var(--ink).

Brand style roles. A brand can also set: button radius, weight, case and shadow (none, soft, firm or lifted, mapped to the three shadow tokens plus the bevel); an outline secondary button; input radius and border strength (subtle, normal, strong); card radius and shadow; display weight, case and tracking; and the marker colour (kept readable behind ink).

Colour rules#

  • Every colour is a token or a color-mix() of tokens. Hex appears only as the last fallback inside var().
  • Text follows the surface it sits on: --ink on surface and card, --band-ink on a band, --button-ink on buttons.
  • Text links use color: var(--link, var(--accent)), underlined with text-decoration-color: oklch(from var(--link, var(--accent)) l c h / 0.45) and text-underline-offset: 0.18em. On hover: oklch(from var(--link, var(--accent)) calc(l - 0.08) c h) with a solid underline. On a band, links use --band-ink, underlined. Links styled as buttons follow the button tokens.
  • The decline link ("No thanks, I'll pass…") stays quiet: --muted or --ink, underlined, so it never competes with the button.
  • Exceptions keep their own colours: official third-party marks (payment networks, Google, Outlook and Apple calendar marks, social and app-store logos), photographs and generated images, the marker's yellow fallback, and pure black alpha shadows. The exception covers only the mark itself, never the button, card or text around it. Mark an official SVG with data-official-mark="Provider name". Generic icons still use tokens.

Type#

  • Headlines use var(--font-display); everything else uses var(--font-body). A piece never sets a face of its own.
  • The one exception is a face integral to the piece, such as a handwritten signature, set through a scoped variable: --signature-font: var(--signature-face, var(--font-display)).
  • Scale and size are the piece's design. Weight and case go through --display-weight and --display-case.
  • Load every weight and style the page uses. Asking for 800 while loading only 400 gives a fake bold.
  • At most two families on a page.

Images: brand slots#

Images are part of the theme. Each image a piece shows fills a named slot. A brand that supplies the slot replaces the image; a brand that doesn't keeps the image the piece was designed with.

Slot What it is Brand image role
logo Brand mark logo
product Main product shot or cover, transparent background product (the first)
item-1 … item-n Offer items and bonuses product (the rest, in order)
presenter Author, coach or speaker portrait team
presenter-cutout The same person on a transparent background team
signature Handwritten signature image other
scene Photographic scene or lifestyle shot lifestyle
seal-guarantee Money-back seal or badge, transparent background other
stamp Decorative stamp or postmark, transparent background other
texture Subtle background texture texture
  • Pieces take images as src props named after the slot (productImage, presenterImage). Pass the brand's image to the prop.
  • In a themed preview, the registry's slot(name, designedImage) helper returns the theme's image for that slot, or the designed image. Call it during render, never cache it outside.
  • A slot image must work at any likely aspect: object-fit: cover with a sensible object-position, or contain for transparent product and seal art.
  • Supplied image URLs must load. A missing slot falls back to the designed image; a broken URL does not.

Previews#

The pack's theme-message.js exports themeMessage(theme, custom), which turns a preset or brand theme into the message every library preview listens for. Post it to a preview iframe to restyle it live; send it again to switch themes. A message with no images restores the designed art. Only the parent window can theme a preview.

A themed piece#

A piece is themed when all of these hold:

  1. No fixed hex outside a var() fallback, except the documented exceptions.
  2. No font family other than the display and body tokens, or a documented signature variable.
  3. Its specimen sets no tokens or fonts on its wrapper.
  4. Buttons, inputs, cards and highlights read the role tokens.
  5. Every image goes through a slot.
  6. Under a light theme, a dark theme and high-contrast extremes (black and yellow, saturated green), at 1440px and 390px, every text pair reads at 4.5:1 and nothing overflows.

Are you sure?