Components/FlatSelect

FlatSelect

A dropdown whose options expand over the trigger from the selected item.

VerifiedSince 0.3.4

Usage

Basic

Loading demo...

Disabled

Set disabled on the whole group or on single items.

Loading demo...

Release Policy

An admin flow: Cascader sets the scope, FlatSelect the policy, sliders the thresholds, and TagInput the labels.

Loading demo...

Best Practices

  • Use for three to six short, stable options; use TxSelect for search, remote data, grouping, or virtualization.
  • Keep labels short: the trigger and the items both truncate to one line.
  • Keep each value stable and unique: the parent matches selection and keyboard order by value.
  • Don't put interactive controls inside TxFlatSelectItem; the item is already a button with role="option".
  • Mark unavailable options disabled instead of filtering them out.

API Reference

TxFlatSelect

Props

PropTypeDefaultDescription
modelValue / v-modelstring | number''The selected value, matching one item's value; shows the placeholder when nothing matches.
placeholderstring''Trigger text while nothing is selected.
disabledbooleanfalseDisables the group: the trigger can't be clicked and the dropdown won't open.

Events

EventParamsDescription
update:modelValue(value: string | number) => voidFires on every commit, including ArrowUp/ArrowDown navigation.
change(value: string | number) => voidFires together with update:modelValue.

Slots

SlotDescription
defaultTxFlatSelectItem children.

TxFlatSelectItem

Props

PropTypeDefaultDescription
valuestring | number-The option value; keep it stable and unique.
labelstring-Text shown in the trigger and the option.
disabledbooleanfalseMakes the option unselectable and skipped by the keyboard.

Slots

SlotDescription
defaultCustom content, replacing label.

Comparison with TxSelect

FeatureTxSelectTxFlatSelect
Positioningfloating-ui, teleported to bodyCSS absolute + clip-path
ExpansionPanel appears below the triggerOptions overlay the trigger, expanding from the selected item
AnimationNone (avoids scroll lag)clip-path expand / collapse
SearchSupportedNot supported
Use caseGeneral and complex formsSettings pages, simple dropdowns
TriggerInput-styleButton-style with arrow

Overview

  • The trigger is role="combobox", the panel role="listbox", and each item a role="option" with aria-selected.
  • Options overlay the trigger, with the selected item anchored at the trigger's position.
  • While open, ArrowUp / ArrowDown move and commit immediately, skipping disabled items.
  • Closing collapses the panel onto the trigger and fades its surface, border, shadow, and selected accent over the same 200ms.

Technologies

  • Source: packages/tuffex/packages/components/src/flat-select/.
查看源码
packages/tuffex/packages/components/src/flat-select/index.ts