@preset
Declares a group of attribute values that constructs take by type or by name.
On this page
#Attributes
nodeThe construct type the preset is for, written as the implicit value:
:curve. Without an id the preset applies to every construct of that type after it; with one, #accent:curve, only to a curve that names it.Can be written as shorthand:
:value#Examples
@preset:text(text size: 24)@preset#accent(colour: orange; width: 4)
graph{
curve(expression: x^2; preset: #accent)
}@preset#faint:curve(colour: grey; width: 1)
graph{
curve(expression: x^2)
curve(expression: x^2 + 1; preset: #faint)
}#Notes
- A preset with an id is applied by name,
preset: #accent, or several at once,preset: #faint, #accent, a later one over an earlier. - An attribute written on the construct wins over a named preset, which wins over a preset by type, which wins over the attribute's default.
- A preset by type reaches the constructs after it inside the construct that holds it; a second one for the same type replaces it from there.
- A named preset is declared before use: unknown preset
#accent— presets must be declared before use. - Presets apply to block constructs only, cannot name other presets, and do not apply to a
@defineuse. - A preset with neither a type nor an id is refused: @preset: missing target: use
:node,#id, or#id:node. - A preset with a body is refused: @preset: takes attributes only.
- An attribute the type does not have is refused: @preset: node
curvedoes not declare an attributenosuch. - A micronode as the type is refused: @preset:
boldis a micronode — node presets apply to block nodes only. preset:inside a preset is refused: @preset: presets cannot reference other presets.- A typed preset applied to another type is refused: preset
#accentis scoped tocurvenodes and cannot apply to nodepoint. - An id already taken is refused: duplicate id
#apple— already declared by a preset at line 7. - A preset's id used as a reference is refused: id
#anames a preset — references target nodes and micronodes.