Skip to main content
Substrate’s web output has two layers that work together. The generated CSS establishes a cascade built entirely from continuous scalars composed with calc(), and the JavaScript runtime solves APCA contrast against the actual surface and writes the results back as custom properties. APCA attribution and use restrictions: see About APCA.
A JavaScript runtime is required. The static CSS includes a baked no-JS snapshot so a server-rendered page paints accessibly at first paint, but that snapshot is an accessible floor covering the page surface under four preset combinations. Continuous scheme positions, CVD compensation, warmth, density, and scoped surfaces all need the runtime.

Getting the CSS

The pipeline writes into generated/, with globally shared artifacts under generated/global/ and per-brand artifacts under generated/brands/<brand>/<sub-brand>/. Load the barrel once at your app entry — it pulls in the layer definitions, the token layer, the @property declarations, the role selectors, every brand’s CSS, the component styles, and the CVD pattern overlays:
initializeSubstrate() defaults to the first registry brand and defaultPreferences(), accepts { brand, preferences } overrides, and is exactly equivalent to the lower-level sequence:
Any preference change repeats the last two sync calls. The substrate setup path generates this module for you as src/substrate.setup.ts. Full detail on the call sequence and the alias contract is on the Runtime & Imports page; nested surfaces need the Surface component.

Using it in your CSS

Opt an element into the cascade with data-ucs and give it a role:
Then compose colors from the primitives the same way the generated CSS does:
Because you compose from primitives rather than hard-coded colors, the same rule tracks every preference change automatically — scheme, contrast, CVD, and warmth all flow through without a second declaration.

Other output targets

CSS is one target among several. The same brand model is emitted as DTCG JSON (the W3C design-token format, for Tokens Studio and Style Dictionary), Swift, Kotlin/Compose, React Native, Xcode asset catalogs, and JSON conformance vectors used to hold the native kernel ports to the TypeScript kernel’s behavior.

Runtime & Imports

The runtime call sequence and the three import aliases.

Surface Component

Re-solving contrast against a nested surface’s own background.

iOS / Swift

Per-mode Display P3 token files and the SubstrateKernel package.