Custom properties
Runtime customization: every forma-css token is a CSS custom property. Set them on :root or scope them per element \u2014 no rebuild needed.
Description
Every token in forma-css is a CSS custom property with the --forma- prefix. Set them on :root to retheme the whole site, or on any element to scope the change: forma resolves everything at runtime, wrapped in light-dark(), so one rule serves both themes.
Colors get a -dark custom property for each light one; if you leave the -dark unset, its fallback chain resolves to the light value, so dark mode never breaks. A typical theme only needs a handful of declarations:
:root {
--forma-color-primary: #083cc0;
--forma-color-primary-dark: oklch(70% 0.12 250);
--forma-color-background: white;
--forma-color-background-dark: oklch(20% 0.02 250);
--forma-color-text: #222;
--forma-color-text-dark: white;
--forma-color-success: green;
--forma-color-success-dark: #4caf50;
--forma-font-family: "Inter", sans-serif;
--forma-border-radius-button: 0.25rem;
--forma-transition-fast: 0.15s;
}No build step, no recompile: the compiled forma-css stays untouched and users can even switch themes at runtime. Setting a variable on a component scope only affects that subtree, so micro-themes (a warning card, a dark footer) cost one declaration.
Prefer oklch or relative colors for brand colors so hover, active and secondary states keep deriving automatically. Scope overrides on the closest element instead of :root whenever you can, and keep dark variants next to their light value.
Retheme without rebuilding
Two declarations scoped to a div retheme the subtree: primary color and button radius, no rebuild involved. The same tokens on :root retheme the whole site.
<div style="--forma-color-primary: oklch(55% 0.2 150); --forma-border-radius-button: 1.25em;">
<button>Themed button</button>
<a href="#">Themed link</a>
</div>All custom properties
The full reference. The color table lists both custom properties, light and dark, side by side; tokens outside the color group are identical in both modes. Icon variables have no default: you point them at your own inline SVG image. The --forma- prefix itself comes from $css-var-prefix in the Sass config, so rebranding the prefix is a build-time change.
Colors
How the fallback works: the -dark property does not have a fixed fallback color. It falls back to its light twin, so --forma-color-primary-dark resolves to var(--forma-color-primary), and only to #083cc0 if you have not redefined primary either. This is why primary and secondary show the same default in both columns: in dark mode they simply take the light value unless you define the -dark variant. If you only redefine --forma-color-primary, dark mode follows your new value automatically.
| Light mode | Dark mode | Default (light) | Default (dark) | Controls |
|---|---|---|---|---|
--forma-color-primary | --forma-color-primary-dark | #083cc0 | #083cc0 | Brand primary: buttons, links, active states |
--forma-color-secondary | --forma-color-secondary-dark | #05a5d1 | #05a5d1 | Secondary accents |
--forma-color-text | --forma-color-text-dark | #222 | white | Body text and currentColor icons |
--forma-color-background | --forma-color-background-dark | white | #2a2a2a | Page background |
--forma-color-backdrop | --forma-color-backdrop-dark | white 40% | black 20% | Overlay behind modals, off-canvas, toasts |
--forma-color-panel | --forma-color-panel-dark | white | black | Cards, modals, dropdowns, nav bars |
--forma-color-border-panel | --forma-color-border-panel-dark | #e0e0e0 | #2a2a2a | Borders of panels and inputs |
--forma-color-gray-highlight | --forma-color-gray-highlight-dark | #cccccc | #505050 | Subtle borders, disabled fills, switch tracks |
--forma-color-success | --forma-color-success-dark | green | #4caf50 | Valid state, .text-success |
--forma-color-danger | --forma-color-danger-dark | #ff4800 | #ff7043 | Invalid state, .text-danger |
--forma-color-info | --forma-color-info-dark | #0059ff | #5b8cff | Info highlights, .text-info |
--forma-color-warning | --forma-color-warning-dark | #fef600 | #ffe014 | Warning highlights, .text-warning |
Typography
| Property | Default | Controls |
|---|---|---|
--forma-font-family | Arial | Body text |
--forma-font-family-headings | Arial | Headings h1–h6 |
--forma-font-family-buttons | Arial | Buttons and form controls |
--forma-font-weight | normal | Base font weight |
--forma-line-height | 120% | Base line height |
--forma-font-size-base | 16px | Root size the breakpoint scale multiplies |
--forma-font-size | 16px | Base element font size |
Spacing and scale
| Property | Default | Controls |
|---|---|---|
--forma-gutter | 1em | Grid and layout gutter |
--forma-scale-sm | 0.7 | .sm utility scale (badge, small text) |
--forma-scale-lg | 1.3 | .lg utility scale |
--forma-scale-xl | 1.5 | .xl utility scale |
--forma-mobile-modal-margin | 0em | Margin around full-screen mobile modals |
Shape, motion and depth
| Property | Default | Controls |
|---|---|---|
--forma-border-radius-panel | 0.5rem | Corner radius of cards, modals, inputs |
--forma-border-radius-button | 0.25rem | Corner radius of buttons |
--forma-transition-slow | 0.5s | Slow transitions (modals, off-canvas) |
--forma-transition-fast | 0.2s | Fast transitions (hover, focus) |
--forma-elevation-1 | 0 0 0.25rem rgba(0,0,0,.2) | Level 1 shadow: cards, nav |
--forma-elevation-2 | 0 0 0.75rem rgba(0,0,0,.3) | Level 2 shadow: focus, dropdowns, inputs |
--forma-elevation-3 | 0 0 1.5rem rgba(0,0,0,.4) | Level 3 shadow: modals, toasts |
--forma-filter-backdrop | none | Filter applied to overlays (e.g. blur(2px)) |
--forma-filter-panel | none | Filter applied to panels |
Form icons
| Property | Default | Controls |
|---|---|---|
--forma-icon-search | – | Magnifier of the search input and hidden search |
--forma-icon-date | – | Calendar icon of date inputs |
--forma-icon-time | – | Clock icon of time inputs |
--forma-icon-expand | – | Chevron of selects and accordions |
--forma-icon-check | – | Check inside checkboxes |
--forma-icon-invalid-true | – | Icon shown when aria-invalid="true" |
--forma-icon-invalid-false | – | Icon shown when aria-invalid="false" |