- docs/design-tokens.md (new module page), README index, CHANGELOG - AGENT.md §0b row 19, §6.11 rewritten for the standard, §6.11a, §7, §10, §12, §14 - ipal-setup stage 5, ipal-block section-code (Section with data-surface, Button, card on token utilities), ipal-site phase 8, ipal-reference (+ api.md /tokens section), ipal-upgrade 1.15.0 note, ipal-audit SKILL + audit.sh token checks - theme.md, consent.md, accessibility.md (a11y.css), lightbox.md, PROGRAMISTA §2.5 - /tokens entry lists its exports explicitly; docs coverage test includes it Co-Authored-By: Claude Opus 5.5 <[email protected]>
12 KiB
Design tokens — one standard, every brand (1.15.0)
Every site built on ipal-kit uses the same token names (--ipal-*), the same scale, the same dark-mode
mechanism and the same Tailwind utilities. Only the values differ per brand. Components (the shared blocks,
the plugin's own UI, the project's sections) read only tokens, so a new brand is a new DESIGN.md plus one
tokens file. Nobody edits a component.
Everything here is opt-in. A site that imports none of it looks exactly as before. Every value can be overridden.
What the plugin ships
| Export | What it is |
|---|---|
@intecion/ipal-kit/tokens.css |
neutral defaults for every token: light on :root, dark on :root[data-theme="dark"], the inverse scope, reduced motion |
@intecion/ipal-kit/tailwind.css |
Tailwind 4 preset: @theme inline map (utilities below), dark: on data-theme, duration-* / z-* utilities, a small base layer, the theme-switch transition |
@intecion/ipal-kit/fluid-wide.css / fluid.css |
the type and space scale (--ipal-fs-*, --ipal-space-*, containers, height helpers): grows to 1920 px / 1280 px |
@intecion/ipal-kit/a11y.css |
optional CSS for the accessibility widget's attributes, working through the tokens (accessibility.md) |
@intecion/ipal-kit/tokens |
TS entry with no Payload/React import: defineTokens, IPAL_TOKENS, ipalVar, IPAL_BREAKPOINTS, tokensToCss, contrastReport, fluidClamp … |
ipal-tokens (bin) |
src/design/tokens.ts → src/design/tokens.css + WCAG contrast check |
defineTokens, IPAL_TOKENS, ipalVar, IPAL_BREAKPOINTS and the types IpalTokenName, TokensInput are also
exported from the root entry (@intecion/ipal-kit).
Wiring (a new site)
/* src/app/(frontend)/styles.css — the same on every site */
@import "tailwindcss";
@import "@intecion/ipal-kit/fluid-wide.css"; /* default for new sites; or fluid.css */
@import "@intecion/ipal-kit/tokens.css"; /* neutral defaults */
@import "@intecion/ipal-kit/tailwind.css"; /* utilities, dark variant, base layer */
@import "../../design/tokens.css"; /* the brand — generated, always last */
@source "../../../node_modules/@intecion/ipal-kit/dist/**/*.js";
// src/design/tokens.ts — the ONLY file you edit to rebrand (template: ipal-setup/resources/tokens.ts)
import { defineTokens } from '@intecion/ipal-kit/tokens'
export const tokens = defineTokens({
theme: 'both', // 'light' | 'dark' | 'both' — match Site settings → Theme
fluid: 'wide', // the fluid file styles.css imports
color: {
light: { primary: 'oklch(0.5 0.17 250)', accent: 'oklch(0.78 0.15 85)' },
dark: { bg: 'oklch(0.16 0.01 250)' }, // brand roles left out carry over from light
},
font: { fwHeading: 700 },
radius: { control: '999px', card: '1.25rem' },
fs: { h1: ['2.25rem', '4rem'] }, // min → max; the clamp() is computed for the fluid range
})
pnpm exec ipal-tokens
// src/app/(frontend)/[locale]/layout.tsx — fonts in the two fixed slots
const body = Inter({ subsets: ['latin', 'latin-ext'], variable: '--font-family-body', display: 'swap' })
const heading = Fraunces({ subsets: ['latin', 'latin-ext'], variable: '--font-family-heading', display: 'swap' })
<html lang={locale} className={`${body.variable} ${heading.variable}`} suppressHydrationWarning>
The slots are --font-family-body / --font-family-heading (and --font-family-mono), never --font-body.
--font-body is the Tailwind key behind font-body, and that key maps back to the token, so the two would form a var() cycle.
Dark mode: <SiteProviders theme> (theme.md). Nothing else is needed: the roles switch on data-theme.
Check.
pnpm exec ipal-tokens --check→✓ … up to date.pnpm exec ipal-tokensexits 0, with no ✗ rows.- In the browser,
getComputedStyle(document.documentElement).getPropertyValue('--ipal-primary')returns the brand value. - Switch the theme:
--ipal-bgchanges. - The cookie banner uses the brand colour in both themes.
The tokens
Colour roles (switch with the theme)
Token --ipal-… |
Role | Utility |
|---|---|---|
bg |
page background (settings.background = default) |
bg-bg |
surface |
card, panel, banner | bg-surface |
surface-muted |
alternate section (muted) |
bg-surface-muted |
surface-raised |
header, popover, dropdown | bg-surface-raised |
surface-inverse / text-inverse |
inverted section (inverted) |
bg-inverse / text-on-inverse |
text · text-strong · text-muted |
body · headings · captions | text-fg · text-fg-strong · text-fg-muted |
border · border-strong |
dividers, inputs, cards | border-border · border-border-strong |
primary · primary-hover · primary-text |
main buttons, key accents | bg-primary · hover:bg-primary-hover · text-on-primary |
secondary · secondary-hover · secondary-text |
second button (default: neutral strong) | bg-secondary · text-on-secondary |
accent · accent-text |
highlight, badge, rating stars (default: primary) | bg-accent · text-accent · text-on-accent |
link · link-hover |
links in running text | text-link · hover:text-link-hover |
link-inverse · focus-inverse |
link and focus ring inside an inverted section | (read through the inverse scope) |
hover |
neutral hover (ghost button, row) | bg-hover |
focus |
focus ring | outline-focus · ring-focus |
overlay |
scrim, hero image overlay | bg-overlay · from-overlay |
success · warning · danger · info (+ -surface) |
form and status states | text-danger · bg-danger-surface … |
Unset hovers, links and focus derive from primary with color-mix(in oklch, …). Write values in oklch (the
standard). Any CSS colour works.
Type, space, shape, motion
| Group | Tokens | Utilities |
|---|---|---|
| Fonts | font-body, font-heading, font-mono; fw-body, fw-heading, lh-body, lh-heading, tracking-heading |
font-body (= font-sans), font-heading, font-mono, leading-body, leading-heading, tracking-heading |
| Sizes (fluid) | fs-xs, fs-sm, fs-base, fs-lg, fs-h4, fs-h3, fs-h2, fs-h1, fs-display |
text-xs … text-display, text-lead (= fs-lg) |
| Space (fluid) | space-stack, space-gap, space-gutter, space-section-sm, space-section |
space-y-stack/mt-stack, gap-gap, px-gutter, py-section-sm, py-section |
| Radius | radius (controls), radius-sm, radius-card, radius-media, radius-full |
rounded-control, rounded-sm, rounded-card, rounded-media, rounded-full |
| Shadow | shadow-sm, shadow-md, shadow-lg (dark theme: deeper + hairline ring) |
shadow-sm/md/lg |
| Layout | container (80rem), container-wide (96rem), container-narrow (48rem), measure (68ch), hero-min-h, *-fit |
max-w-container, max-w-container-wide, max-w-narrow, max-w-measure |
| Motion | duration-fast 150ms, duration 250ms, duration-slow 400ms, ease-out, ease-in-out (all durations 0 with reduced motion or data-a11y-motion="reduce") |
duration-fast, duration-base, duration-slow, ease-out, ease-in-out |
| Layers, focus | z-header 40, z-overlay 50, z-toast 60; focus-width, focus-offset |
z-header, z-overlay, z-toast |
| Breakpoints | fixed: sm 40 · md 48 · lg 64 · xl 80 · 2xl 96 rem (Tailwind defaults); IPAL_BREAKPOINTS for sizes= / matchMedia |
sm: … 2xl: |
A project may add a breakpoint (--breakpoint-xs) as a deviation recorded in DESIGN.md. It never moves an existing one.
Inverted sections
<Section> with settings.background = inverted renders bg-inverse and data-surface="inverse". Inside that
scope, text, text-strong, text-muted, border(-strong), surface, hover, link and focus are re-mapped
for the inverse surface, and color-scheme flips. Cards, rich text, links and focus rings need no inverse variants:
they keep text-fg, text-link, border-border. primary / accent are not re-mapped. The contrast report warns
when primary on surface-inverse is below 3:1.
Legacy -dark names
--ipal-surface-dark, --ipal-text-dark … (the cookie banner's old twins) stay as aliases: in the dark theme
tokens.css sets each to its role. The banner and button now read the single names. Without tokens.css, their
fallback follows the page's color-scheme (light-dark()) and still honours a -dark variable a site sets.
New code never reads -dark.
ipal-tokens
| Command | Does |
|---|---|
pnpm exec ipal-tokens |
writes src/design/tokens.css (only what differs from the defaults), prints the failing contrast pairs, exits 1 on a WCAG AA failure |
--check |
writes nothing; exits 1 when the CSS is out of date (CI, ipal-doctor) |
--report |
prints every checked pair: paste into DESIGN.md → Colour |
--warn-only |
contrast failures do not fail the command |
--in <file> --out <file> |
other paths; --in also takes .mjs / .js / .json |
The input must export tokens (or a default export). .ts needs Node 22.18+ (type stripping). The contrast check
covers text on every surface (4.5:1) in both themes, text on primary/secondary/accent, the inverse scope, the states,
and focus rings (3:1).
Building blocks (@intecion/ipal-kit/tokens)
| Export | Use |
|---|---|
defineTokens(input) |
checks every role and size name, returns the input (type TokensInput, colours ColorInput) |
tokensToCss(input, { source }) |
the brand CSS the CLI writes |
defaultTokensCss() |
the content of tokens.css |
contrastReport(input) → ContrastRow[] |
the WCAG check; contrastRatio(fg, bg), parseColor(css, lookup) for your own pairs |
resolveColors(input) |
each theme's final colour values (defaults + brand) |
fluidClamp(min, max, range) |
the fluid.css clamp() for your own sizes; FLUID_SCALE, FLUID_RANGES, type FluidRange, RemValue |
IPAL_TOKENS, ipalVar(name, fallback?) |
var(--ipal-…) strings for inline styles, charts, a styleguide page (type IpalTokenName) |
IPAL_BREAKPOINTS |
breakpoints in rem |
COLOR_DEFAULTS, STATIC_DEFAULTS, FLUID_TOKENS, INVERSE_SCOPE, LEGACY_DARK_ROLES, DARK_SELECTOR, INVERSE_SELECTOR, type ColorRole |
the catalogue itself |
Values that CSS variables can't reach (next/og images, e-mail templates, <meta name="theme-color">): import tokens
from @/design/tokens and read resolveColors(tokens).light.primary.
DESIGN.md
The template (ipal-setup/resources/DESIGN.md) has nine fixed sections: brand, colour (with the contrast report),
type, shape, layout, motion, imagery, theme, deviations. DESIGN.md is the human source and tokens.ts its machine form.
They must agree. The vendored ext-frontend-design skill may propose a direction, but its palette is mapped onto
these roles in DESIGN.md / tokens.ts after the owner approves. It never adds token names, colours or fonts in components.
Turn off, override, extend
- Turn off: don't import a file.
tokens.csswithouttailwind.cssworks for plain CSS (var(--ipal-…)). Notokens.tsmeans the neutral defaults. A plain-CSS site (no Tailwind) importstokens.cssalone. - Override: every value in
tokens.ts(raw: { 'hero-min-h': '…' }for anything without a field), or plain CSS after the imports. The cookie banner and button also keepclassNames/className. - Extend: project-only tokens (decorative brand colours) go in
styles.cssbelow the imports and inDESIGN.md→ Deviations. A missing role every site would need → plugin gap (ipal-plugin-gap).
Migrating an existing site
ipal-upgradeto 1.15.0, add the imports above andsrc/design/tokens.ts.- Map the site's current
@themecolours to the roles, its fonts to the slots, and its radius, container and fluid pairs intotokens.ts. Keep the old names as aliases (--color-brand: var(--ipal-primary)) in a/* legacy, remove after migration */block, so no component breaks on day one. - Delete the
--ipal-*-darkblock the site kept only to stop the cookie banner going dark. - Replace old utilities and hard-coded values file by file (
ipal-auditlists them). Removedark:colour classes. - Remove the legacy block. Write
DESIGN.mdfrom the template.