Iteration

Generate tokens from lists using /forEach and create multi-axis combinations with /matrix. These are advanced features for generating large sets of token variations.

ForEach

Generate tokens from a single list. Each item creates its own namespace.

Basic List

Creates xs.margin, xs.padding, sm.margin, etc.

Basic List Generate tokens from a single list. Each item creates its own namespace.

Index Keywords

Use index (1-based), index0 (0-based), or index1 (1-based explicit) for position-based calculations.

Index Keywords Use index (1-based), index0 (0-based), or index1 for position-based calculations.

Dynamic Collection Access

Use index inside bracket selectors for dynamic lookups:

a→sp02(12), b→sp03(16), c→sp04(20)
Dynamic Collection Access Use index inside bracket selectors for dynamic lookups.

inEach Values

Assign different values for each iteration position. Array length must match the list length.

Positional Values

mobile gets 14/8, desktop gets 18/12.

Positional Values Assign different values for each iteration position.

With Multiple Properties

Works with numbers, strings, colors — any value type:

With Multiple Properties Works with numbers, strings, colors — any value type.

Matrix (Multi-Axis)

/matrix creates Cartesian products — 2×2 axes produce 4 combinations, 3×2 produce 6, etc.

Basic Grid

2 colors × 2 themes = 4 combinations.

Basic Grid /matrix creates Cartesian products — 2×2 axes produce 4 combinations.

Multi-Axis inEach

In matrices, use inEach.axisName[] to specify which axis values map to:

Multi-Axis inEach In matrices, use inEach.axisName[] to specify which axis values map to.

Multiple Dimensions

Nest axes as deep as needed. Use aliases in expressions and dynamic references.

3 devices × 2 densities = 6 combinations
Multiple Dimensions Nest axes as deep as needed. Use aliases in expressions and dynamic references.

Real-World: Responsive Typography

Combine matrix with number scales and pipelines for a complete type system:

Real-World: Responsive Typography Combine matrix with number scales and pipelines for a complete type system.

Alias uses: The as keyword creates aliases used in token names ({color}), expressions (calc($base * {multiplier})), and dynamic references ($...{device}.fontSize).

Next: Conditionals — control token generation with if/else logic.