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.

Themed link
HTML
<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 modeDark modeDefault (light)Default (dark)Controls
--forma-color-primary--forma-color-primary-dark#083cc0#083cc0Brand primary: buttons, links, active states
--forma-color-secondary--forma-color-secondary-dark#05a5d1#05a5d1Secondary accents
--forma-color-text--forma-color-text-dark#222whiteBody text and currentColor icons
--forma-color-background--forma-color-background-darkwhite#2a2a2aPage background
--forma-color-backdrop--forma-color-backdrop-darkwhite 40%black 20%Overlay behind modals, off-canvas, toasts
--forma-color-panel--forma-color-panel-darkwhiteblackCards, modals, dropdowns, nav bars
--forma-color-border-panel--forma-color-border-panel-dark#e0e0e0#2a2a2aBorders of panels and inputs
--forma-color-gray-highlight--forma-color-gray-highlight-dark#cccccc#505050Subtle borders, disabled fills, switch tracks
--forma-color-success--forma-color-success-darkgreen#4caf50Valid state, .text-success
--forma-color-danger--forma-color-danger-dark#ff4800#ff7043Invalid state, .text-danger
--forma-color-info--forma-color-info-dark#0059ff#5b8cffInfo highlights, .text-info
--forma-color-warning--forma-color-warning-dark#fef600#ffe014Warning highlights, .text-warning

Typography

PropertyDefaultControls
--forma-font-familyArialBody text
--forma-font-family-headingsArialHeadings h1–h6
--forma-font-family-buttonsArialButtons and form controls
--forma-font-weightnormalBase font weight
--forma-line-height120%Base line height
--forma-font-size-base16pxRoot size the breakpoint scale multiplies
--forma-font-size16pxBase element font size

Spacing and scale

PropertyDefaultControls
--forma-gutter1emGrid and layout gutter
--forma-scale-sm0.7.sm utility scale (badge, small text)
--forma-scale-lg1.3.lg utility scale
--forma-scale-xl1.5.xl utility scale
--forma-mobile-modal-margin0emMargin around full-screen mobile modals

Shape, motion and depth

PropertyDefaultControls
--forma-border-radius-panel0.5remCorner radius of cards, modals, inputs
--forma-border-radius-button0.25remCorner radius of buttons
--forma-transition-slow0.5sSlow transitions (modals, off-canvas)
--forma-transition-fast0.2sFast transitions (hover, focus)
--forma-elevation-10 0 0.25rem rgba(0,0,0,.2)Level 1 shadow: cards, nav
--forma-elevation-20 0 0.75rem rgba(0,0,0,.3)Level 2 shadow: focus, dropdowns, inputs
--forma-elevation-30 0 1.5rem rgba(0,0,0,.4)Level 3 shadow: modals, toasts
--forma-filter-backdropnoneFilter applied to overlays (e.g. blur(2px))
--forma-filter-panelnoneFilter applied to panels

Form icons

PropertyDefaultControls
--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"