Select
A control for choosing one or more values from a dropdown list.
Usage
Basic
Local Filtering
searchable renders a search field in the panel that filters registered option labels.
Remote Search
Pair remote with editable: the trigger becomes editable and typing emits search while the panel is open. Show pending results with loading.
Multiple Tags
With multiple, v-model is an array; clicking an option toggles it and keeps the panel open.
Inline Creation
With allowCreate, Enter or the footer button emits create from the current input and selects the new value.
Groups and Footer
options accepts { label, options } groups; the footer slot holds add buttons, helper text, or shortcuts.
Icons and Descriptions
Options can carry an icon (a class resolved by the host app's styles) and a second-line description.
Status Border
status only draws the border; keep validation messages in the form item.
Disabled
Disable the whole select when the value is read-only; disable a single TuffSelectItem to keep an unavailable choice in the list.
Scrolling Panel
dropdownMaxHeight caps the panel height; on open, the selected item scrolls into view.
Width
The trigger defaults to 240px and the panel always matches it; set a width on the component to change both.
Best Practices
- Use
optionsfor data-driven lists andTuffSelectItemfor a few static items with inline markup; don't mix the two. - Name a single select with an adjacent
<label for>andid, oraria-label; name a multiple select witharia-label/aria-labelledby. Don't wrap the select in a label. - Keep remote requests in the host and limit them with
searchDebounce. - To show a created option again, add it to your own
optionsin thecreatehandler. - Match
modelValuetomultiple: a scalar for single, an array for multiple.
API Reference
TuffSelect
Props
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue / v-model | string | number | Array<string | number> | '' | Selected value; an array with multiple. |
placeholder | string | 'Please select' | Trigger placeholder when nothing is selected. |
disabled | boolean | false | Disables the trigger, closes the panel, and blocks selection. |
multiple | boolean | false | Multiple selection, shown as tags. |
status | 'default' | 'error' | 'warning' | 'default' | Validation border state. |
eager | boolean | true | Mounts the panel up front so slot options register reliably. |
options | TxSelectOptionLike[] | [] | Plain or grouped options. |
maxTagCount | number | - | Maximum visible tags; the rest collapse into + N .... |
maxTagTextLength | number | - | Maximum tag text length before truncation. |
searchable | boolean | false | Shows a local search field in the panel when not editable. |
searchPlaceholder | string | 'Search' | Placeholder of the panel search field. |
editable | boolean | false | Makes the trigger text editable as the query and opens on focus. |
remote | boolean | false | Editable remote mode; emits search while the panel is open. |
allowCreate | boolean | false | Allows creating an option from the current input. |
createText | string | 'Add item' | Label of the default create button. |
loading | boolean | false | Shows the loading state. |
loadingText | string | 'Loading...' | Default loading text. |
emptyText | string | 'No results' | Default empty text. |
searchDebounce | number | 0 | Debounce of the remote search, in milliseconds. |
dropdownMaxHeight | number | 280 | Maximum panel list height in pixels. |
dropdownOffset | number | 6 | Distance between the panel and the trigger. |
contentPadding | number | 8 | Spacing inside the panel. |
optionPadding | number | 0 | Horizontal inset compensation for options. |
animation | BaseAnchorAnimationOptions | - | Animation options forwarded to Popover / BaseAnchor. |
panelVariant | 'solid' | 'dashed' | 'plain' | 'solid' | Panel surface style. |
panelBackground | 'pure' | 'mask' | 'blur' | 'glass' | 'refraction' | 'refraction' | Panel background. |
panelShadow | 'none' | 'soft' | 'medium' | 'soft' | Panel shadow strength. |
panelRadius | number | 18 | Panel corner radius. |
panelPadding | number | 0 | Panel padding. |
panelCard | BaseAnchorPanelCardProps | - | Card overrides forwarded to the panel. |
Events
| Event | Params | Description |
|---|---|---|
update:modelValue | (value: string | number | Array<string | number>) | Fires after a selection or clear; an array with multiple. |
change | (value: string | number | Array<string | number>) | Fires together with update:modelValue. |
search | (query: string) | In remote mode, fires when the input text changes while the panel is open. |
create | (option: TxSelectOption) | Fires when allowCreate creates an option from the input. |
Slots
| Slot | Props | Description |
|---|---|---|
default | - | Options declared with TuffSelectItem (legacy form). |
option | { option, selected } | Content of one option in options mode. |
tag | { option, remove } | Content of a selected tag. |
group | { group } | Group heading. |
loading | - | Loading state. |
empty | - | Empty state. |
footer | { query, canCreate, create } | Panel footer content. |
Exposed Methods
| Method | Description |
|---|---|
open() | Opens the panel. |
close() | Closes the panel. |
toggle() | Toggles the panel. |
focus() | Focuses the trigger input. |
blur() | Blurs the trigger input. |
clear() | Clears the value and selected label; emits '' in single mode, [] in multiple mode. |
TuffSelectItem
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | number | - | Value written to the select when picked. |
label | string | - | Displayed and selected-state text; defaults to the slot text. |
disabled | boolean | false | Can't be picked but stays in the list. |
icon | string | - | Class of the leading icon, resolved by the host app's styles. |
description | string | - | Secondary text under the label. |
Types
type TxSelectValue = string | number
interface TxSelectOption {
value: TxSelectValue
label: string
disabled?: boolean
icon?: string
description?: string
}
interface TxSelectOptionGroup {
label: string
disabled?: boolean
options: TxSelectOption[]
}
type TxSelectOptionLike = TxSelectOption | TxSelectOptionGroup
Overview
- When
optionsis set it renders the list, andTuffSelectItemregisters only without it. A missinglabelfalls back to the slot text, then the raw value. - In non-editable mode, clicking the trigger toggles the panel; with
editableorremote, focus opens it. - A single select closes after an enabled option is picked; a multiple select stays open.
searchablefilters locally only when not editable;remoteturns local filtering off and emitssearchonly while the panel is open.- A value passed before its options mount gets its label once they register; finite numeric strings and numbers match by numeric value.
- The trigger is a
combobox(aria-haspopup="listbox",aria-expanded), the list alistbox(aria-multiselectablewithmultiple), and each option anoptionwitharia-selected.idand accessible names land on the actual combobox;classandstylestay on the root.
Technologies
- The panel renders through Popover;
TuffSelectItemregisters its value and label with the parent through injection. - Source:
packages/tuffex/packages/components/src/select/; exportsTuffSelectandTuffSelectItem(aliasesTxSelect,TxSelectItem) and the public types.