R241 Write a page’s colors, sizes and timings as design tokens

On by default

In a page’s styles, name a design token for every color, font size, font weight, spacing, corner radius, shadow, duration and easing, and write the value itself only where the tokens are defined.

Reason

A value defined once under a name is changed in one place and is the same wherever it is used. Written out again at each use, the same color or space drifts into near copies that nobody chose, and changing it means finding every one of them (Art. III §4).

Verification

A design token is a named value defined in one place of the repository, such as a CSS custom property or a key of a framework’s theme. Values that are not a choice of the design may be written as they are: 0, auto, 100%, the width of a 1px or 2px border, a breakpoint in a media query, where a token cannot stand, and an offset that sets a single glyph in its line, with a comment saying so.

Violated when a change writes, outside the definition of the tokens, a color, font size, font weight, spacing, corner radius, shadow, duration or easing of a page as a value rather than a token, other than the values above.

Provisions of the constitution it cites

Relations

Parent
R240 Frontend
Requires
none
Conflicts with
none

Metadata

ID
241
Revision
1
Kind
rule
Status
trial
Slug
frontend-design-tokens
Default level
project
Constitution revisions
>=1
Check
none
Default
on
Uses
Instructions instructions, Review review
Original language
English en
Translations
Chinese zh