<t-select>
A word the reader clicks to pick from a menu of options, and types to search it. For lists too long
to cycle through with a <t-choice>.
Without air, a ball dropped from
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. |
previous | A variable to hold the value from before the last pick. |
The options work as in <t-choice>: the reader sees the label,
expressions get the value, and values that look like numbers become numbers.
Interaction
| Input | Effect |
|---|---|
| Click, Enter, Space or ↓ | Opens the menu. |
| Typing a letter | Opens the menu and starts a search with it. |
| ← or → | The previous or next option, without opening the menu. |
In the menu, typing narrows the list: labels that start with what you typed come first, then labels with a word that starts with it, then the rest that contain it. Hovering or pressing ↑ and ↓ previews each option live on the page, Enter or a click commits it, and Esc or clicking away closes the menu and reverts to the original choice.
Options from JavaScript
For a long or generated list, set the element's options property to { label, value } objects
before adding it to the page. The values can be anything, not just numbers and text:
A cube of iron with sides of
tangleCall makes a <t-select> for a parameter with options and
select: true.
Labels written in the options attribute can't contain commas or colons, since those separate the options.