Expressions
Token values support arithmetic, method chaining, string interpolation, and color functions — letting you compute values instead of hardcoding them.
Arithmetic
Write math directly in token values. Supported operators: +, -, *, /, %. calc() is optional for plain arithmetic, but required if you want to chain methods like .roundTo().
Method Chaining
Chain methods after an expression to post-process the result — round it to a grid, or snap it to the nearest value in another token group.
Rounding
Round a calculated value to the nearest multiple with .roundTo(n). An optional second argument controls direction: up, down, or nearest.
Reference Lookup
Snap a calculated value to the nearest matching token in another group with .reference(group, mode). Modes: nearest, up, down.
Scope Persistence
When an expression starts with a token reference, Systematically DSL automatically searches the same scope for an exact match. If found, the result carries a reference to that token — keeping semantic relationships intact.
When scope persistence triggers: expression starts with $scope.token, no explicit .reference() is used, and the result exactly matches another token in the same scope.
The range() Function
Linearly interpolates between two values across the steps of a scale or iteration. Most commonly used in color generators to define smooth lightness and chroma gradients.
Interpolation
Use {expr} to embed an expression in a value, or inside a string alongside ordinary text. The same braces work in token paths when you iterate — see Iteration.
Color Functions
The colorContrast() function resolves an accessible foreground color for any background — inline, in a single expression. Supports WCAG AA/AAA and APCA targets.
Syntax: colorContrast(background, [target], [sample], [true]) — target defaults to WCAG AA (4.5:1). See Color Generators for the /colorContrast directive that generates a full palette of accessible foreground tokens at once.
Next: Number Scales — generate consistent spacing, typography, and sizing systems automatically.