Reuse™ reference¶
The Reuse reference contains the exact syntax behind reuse features. It covers same_as, delta fields, replacement rules, constants, ref(), and calc() after you have already decided which technique you need.
This page explains those settings precisely and links back to the Reuse overview and complete examples for the functional starting points.
Choose the setting¶
Start with the result you want, then use the corresponding reuse setting shown here.
| You want to... | Use |
|---|---|
| Start another item from the same configuration | same_as |
| Move/resize/change entity by a relative amount | same_as_d... |
| Replace a copied nested list or block | same_as_replace |
| Reuse a fixed number/style/configuration block | constants with ref() |
| Calculate a position, size, or spacing | calc() |
Reuse another item with same_as¶
Use same_as to start another visible item from the same configuration and then change only the settings that differ.
same_as can only refer to an item that appears earlier in the same layout section. Every item receives an ID. If you omit id, the card uses that item's zero-based position in its own section as a text ID: "0", "1", "2", and so on. Numbering starts again in each layout section. When you set id yourself, use that name instead.
Change a reused numeric value by an offset¶
Use same_as_d<field> when a reused item should add a numeric offset to a value it inherits. The target field must already exist on the reused item, and only numeric fields supported by that tool can be changed this way.
For example, same_as_dxpos adds to the inherited xpos, same_as_dwidth adds to width, and same_as_dentity_index adds to the inherited numeric entity index. The offset can be a number, ref(...), or calc(...).
The exact same_as_d<field> names depend on the tool. A field that is not numeric for that tool cannot be changed with a delta.
Replace a copied nested block¶
Use same_as_replace when a copied field must be replaced instead of combined with the inherited field. Each entry can be a top-level field such as color_stops or a nested path such as color_stops.colors.
Because only color_stops.colors is replaced, other inherited color_stops settings remain in place.
Reuse a value or block with constants and ref()¶
Use a constant when the same value or configuration block is needed in several places and should be changed from one definition.
Constant names must start with a letter or underscore and can then contain letters, numbers, and underscores. Do not put dots in a constant name.
ref() can insert a single value, a list, or a complete configuration block. Use dot notation to select a value inside a nested constant, for example ref(theme.warning.stroke). Dot notation selects named properties; it does not use array indexes such as [0]. Each inserted list/object is copied, so changing an inherited block elsewhere does not change the constant itself.
Calculate a value with calc()¶
Use calc() when a configuration value can be derived from another reusable value instead of being repeated manually.
calc() must produce one finite number. It can use numeric constants and numeric values inside nested constant objects. A constant calculated with calc() can use numeric constants declared earlier in the constants: block. Strings, booleans, and lists are not available inside calc(). Supported operators are +, -, *, /, **, and parentheses. Supported functions/constants are sin(), cos(), tan(), abs(), round(), floor(), ceil(), min(), max(), sqrt(), and PI.