Design tokens
Generate
bash
npm install
npm run tokens
npm run presetstools/generate-tokens.mjsuses@material/material-color-utilitiesto generate color roles, type scale, shape, elevation, motion and state layers from a seed;- output:
resources/styles/tokens.cssandtokens.jsonat the repository root; tools/generate-presets.mjswrites the four preset palettes toresources/styles/tokens-presets.css.
CI's tokens job regenerates and checks drift:
bash
npm run tokens
npm run presets
git diff --exit-code -- resources/styles/tokens.css resources/styles/tokens-presets.css tokens.jsonNaming
css
--md-sys-color-*
--md-sys-typescale-*-size / line / weight
--md-sys-shape-corner-*
--md-sys-elevation-*
--md-sys-motion-duration-* / easing-*
--md-sys-state-*-opacityAdding a preset
- Add a name and seed in
tools/generate-presets.mjs; - run
npm run presets; - add the value to
SEEDSinHooks.phpand the language files; - update the theming page and this page;
- check light/dark contrast.
Do not hand-edit generated CSS; CI detects drift.