Controls
Forms
Select
A custom dropdown picker for option sets, playground controls and compact forms.
Component
06
Import
import { Select } from "@swirski/ui";Composition
Field
|-- Label
|-- Select
| `-- options[]
| |-- value
| `-- label
`-- FieldHint | FieldErrorPlayground
Usage
<Select
placeholder="Pick a tone"
defaultValue="yellow"
options={[
{ value: "yellow", label: "Yellow" },
{ value: "blue", label: "Blue" },
{ value: "red", label: "Red" },
{ value: "white", label: "White" },
]}
/>Props
| Prop | Type | Default | Notes |
|---|---|---|---|
Select.contentClassName | string | - | Adds classes to the dropdown content panel. |
Select.defaultValue | string | - | Initial selected option value when uncontrolled. |
Select.disabled | boolean | false | Disables the trigger and prevents selection. |
Select.name | string | - | Adds a hidden input for native form submission. |
Select.onValueChange | ((value: string) => void) | - | Called when a new option is selected. |
Select.optionClassName | string | - | Adds classes to each dropdown option. |
Select.optionsRequired | SelectOption[] | - | Options shown in the dropdown list. |
Select.placeholder | string | "Select an option" | Text shown when no option is selected. |
Select.selectedIndicator | ReactNode | "x" | Generated from SelectProps. |
Select.showSelectedIndicator | boolean | false | Generated from SelectProps. |
Select.size | 'sm' | 'md' | 'lg' | "md" | Generated from SelectProps. |
Select.tone | 'default' | "default" | Generated from SelectProps. |
Select.triggerClassName | string | - | Adds classes to the dropdown trigger. |
Select.value | string | - | Controlled selected option value. |
Select.variant | 'default' | 'filled' | "default" | Generated from SelectProps. |
SelectContent.contentClassName | string | - | Adds classes to the dropdown content panel. |
SelectContent.contentRefRequired | Ref<HTMLDivElement> | - | Generated from SelectContentProps. |
SelectContent.contentStyleRequired | CSSProperties | - | Generated from SelectContentProps. |
SelectContent.highlightedIndexRequired | number | - | Generated from SelectContentProps. |
SelectContent.listboxIdRequired | string | - | Generated from SelectContentProps. |
SelectContent.onOptionHoverRequired | (index: number) => void | - | Generated from SelectContentProps. |
SelectContent.onOptionSelectRequired | (value: string) => void | - | Generated from SelectContentProps. |
SelectContent.optionClassName | string | - | Adds classes to each dropdown option. |
SelectContent.optionsRequired | SelectOption[] | - | Options shown in the dropdown list. |
SelectContent.selectedIndicatorRequired | ReactNode | - | Generated from SelectContentProps. |
SelectContent.selectedValueRequired | string | - | Generated from SelectContentProps. |
SelectContent.showSelectedIndicatorRequired | boolean | - | Generated from SelectContentProps. |
SelectContent.sizeRequired | 'sm' | 'md' | 'lg' | - | Generated from SelectContentProps. |
SelectContent.toneRequired | 'default' | - | Generated from SelectContentProps. |
SelectContent.variantRequired | 'default' | 'filled' | - | Generated from SelectContentProps. |