tuix-dropdown
A select built on tuix-input, with an optional type-to-filter mode.
tuix-dropdown wraps a tuix-input with a list of
options. In single mode the field is read-only and clicking it opens the list;
in search mode typing filters the options.
The list is set as a property. The attribute exists and parses JSON, so
options='["Draft", "Sent"]' works for a short list of plain values, but
anything longer belongs in the property:
Types
Single
The default. The field cannot be typed in; the whole field is the trigger.
Options may be plain values, as here, in which case the label is the value.
Search
Typing filters the list, and blurring restores the label of the selected option.
Description states
The helper line is the input's, so the same five description states apply.
Option types
Keyboard
| Key | Effect |
|---|---|
Enter on the field | Opens or closes the list |
ArrowDown / ArrowUp | Moves through the options |
Enter on an option | Selects it |
Escape | Closes the list |
Clicking anywhere outside the component also closes the list.
API
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
options | options | TuixDropdownOption[] | [] | The list. Property, or JSON in the attribute |
value | value | TuixDropdownOption | None | The selected option. Property, or JSON |
type | type | DropdownType | single | single or search |
title | title | string | '' | Floating label |
placeholder | placeholder | string | '' | Placeholder text |
description | description | string | None | Helper text under the field |
descriptionType | descriptiontype | DescriptionType | text | Helper line state |
disabled | disabled | boolean | false | Blocks opening the list |
dark | dark | boolean | false | Dark palette |
Events
| Event | Detail | When |
|---|---|---|
select | { value: TuixDropdownPlainOption } | An option is chosen by click or Enter |
input-single | { value: string } | The user types, in search mode |
The detail of select is the option's value, never the object. Typed as
CustomEventTuixDropdownSelect and CustomEventTuixDropdownInput.
Notes
- Assigning a new
optionsarray clears the current selection; setvalueagain afterwards if it should survive. - The list is absolutely positioned inside the component, so the dropdown needs room below it, or the page has to scroll.