Select

Single-value dropdown with arrow-key navigation, typeahead, and subtle open/close animation.

Installation

npx dafink-ui add select

Demo

The framework your project uses.

This field is required.

Props

NameTypeDefaultDescription
optionsSelectOption[]-Array of { value, label } objects.
valuestringundefinedControlled selected value.
onChange(value: string) => voidundefinedCalled when a selection is made.
placeholderstring'Select…'Shown when no value is selected.
labelstringundefinedVisible label above the trigger.
hintstringundefinedHelper text (hidden when error is set).
errorstringundefinedError message; switches trigger to error state.
size'sm' | 'md''md'Trigger height and text size.
disabledbooleanfalsePrevents interaction.
classNamestring''Additional classes on the root wrapper.
triggerClassNamestring''Additional classes on the trigger button itself, for restyling the control (className only reaches the outer wrapper).
aria-labelstringundefinedAccessible name for the trigger when there's no visible label (e.g. a compact inline use like a table cell).

Accessibility

The trigger is a native <button> (aria-haspopup="listbox", aria-expanded, aria-controls); opening moves focus to the popup <ul role="listbox"> itself (tabIndex=-1, focused programmatically), which drives the active option via aria-activedescendant rather than moving real DOM focus between role="option" items. Focus is not trapped: Tab closes the list and lets focus continue naturally to the next page element, while Escape closes and explicitly returns focus to the trigger.

KeyFunction
enterOpens the dropdown from the trigger, or confirms the active option and closes when the list is open.
spaceOpens the dropdown from the trigger, or confirms the active option and closes when the list is open.
down arrowMoves the active option to the next one, wrapping from the last to the first.
up arrowMoves the active option to the previous one, wrapping from the first to the last.
homeJumps the active option to the first item.
endJumps the active option to the last item.
escapeCloses the dropdown and returns focus to the trigger.
tabCloses the dropdown without returning focus to the trigger, letting Tab land on the next page element.