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().

Arithmetic Write math directly in token values. calc() is optional.

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.

Rounding .roundTo(n) rounds a value to the nearest multiple, with optional direction.

Reference Lookup

Snap a calculated value to the nearest matching token in another group with .reference(group, mode). Modes: nearest, up, down.

Reference Lookup .reference(group, mode) snaps a value to the nearest token in another group.

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.

Switch to Preview → Table to see the resolved references
Scope Persistence Expressions that start with $scope.token auto-resolve to the matching token in that scope.

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.

Lightness goes from 95 (lightest) to 15 (darkest) across 10 steps
range() Interpolates from start to end across scale steps.

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.

Interpolation Embed expressions in values and strings using curly-brace interpolation.

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.

Without a group to sample, uses pure black or pure white, whichever contrasts more
colorContrast() Resolves an accessible foreground color for a given background.

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.