<t-tag>
An HTML tag whose attributes the reader can change, with the live element right below it.
Drag a number, click a word or toggle an attribute, and the element updates. It works the
other way too: drag the slider below and its value follows.
<t-tag> works like <t-call>: its children are ordinary
<t-num>, <t-choice> and <t-text> elements, and each
one is an attribute. Their values are ordinary variables too, so other elements on the page can use them.
Attributes
| Attribute | Default | Description |
|---|---|---|
tag | div | The element to show: its tag name, plus any attributes that don't change, such as tag='input type="range"'. |
On the children:
| Attribute | Description |
|---|---|
name | The variable. It's also the attribute's name, unless attr is set. |
attr | The attribute's name, when it differs from the variable's. Use it for names that aren't valid variable names, such as aria-label or pixels-per-step. |
content | Marks the child that goes between the opening and closing tags, instead of being an attribute. Put it last. |
Text inside <t-tag> that isn't in a child is fixed content: <t-tag tag="button">Save</t-tag>.
Changing the element
The value and checked attributes go both ways. When the reader moves the slider, types in
the field or ticks the box, the variable behind that attribute changes too, and so does
everything else that reads it.
Values
- Numbers are written the way the child shows them, using its
stepandformat. trueandfalsemake a boolean attribute. The attribute's name is the toggle itself, and it's struck through when the attribute is off. A<t-choice>withoptions="true, false"holds a real boolean.- Text and choices are written as their value. For a choice with
label:valueoptions, the element gets the value, so leave out the labels if the code and the element should match.
Documenting an element
The element can be one of vangle's own, which makes <t-tag> a playground for its
attributes. Change the range or the format, then drag the number in the preview:
Layout
The tag stays on one line while it fits. When it's too wide, each attribute goes on its own line:
<input
type="range"
min="0"
max="100"
step="5"
value="40"
>