<t-choice>
A word the reader clicks to cycle through a list of options. With two options, it's a toggle. For a
long list, use a <t-select>, which opens a menu the reader can search.
Saving
Attributes
| Attribute | Default | Description |
|---|---|---|
name | required | The variable that holds the selected option's value. |
options | required | A comma-separated list. Each option is label or label:value. |
value | text content | The starting option, matched against values first and then labels. Defaults to the first option. |
color | accent color | One CSS color, or two for light and dark mode. |
label | the name | The accessible name. |
Labels and values
The label is what the reader sees. The value is what expressions get. Values that look like numbers
become numbers, so per week:52 gives the variable the number 52, and true and false become
booleans. Without a
:value, the label is the value, and expressions compare against the text:
The trail is
Toggles
A two-option choice with 0 and 1 as values works as a switch. Options named true and false
become real booleans, so options="true, false" works too:
Shipping is
Interaction
| Input | Effect |
|---|---|
| Click | The next option, wrapping around at the end. |
| Shift + click | The previous option. |
| Enter, Space or → | The next option. |
| ← | The previous option. |
Labels can't contain commas or colons, since those separate the options.