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.
Index Keywords
Use index (1-based), index0 (0-based), or index1 (1-based explicit) for position-based calculations.
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.
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.
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.
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.