# Select

A dropdown for picking one option, with full keyboard support.

- **Use it for**: One choice from a known list of up to a few dozen items.
- **Not for**: Long or searchable lists, or several choices. Try [Combobox](https://unseenui.com/components/combobox/), [RadioGroup](https://unseenui.com/components/radio-group/).

## Good to know

- The empty value a form’s hidden native select reports is ignored, so a choice never resets to the placeholder.

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { Select } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<Select variant="outline" value={environment} onValueChange={setEnvironment} options={environments} aria-label="Environment" />
```

## Props

- `value` (`string`): The selected option value, or an empty string.
- `onValueChange` (`(value: string) => void`): Update value with the selected option.
- `options` (`readonly SelectOption[]`): Options need unique, non-empty values and labels. Set disabled on unavailable ones.
- `disabled` (`boolean (optional)`): Prevents opening or changing the selection.
- `dir` (`'ltr' | 'rtl' (optional)`): Sets the control direction. Check the surrounding layout when using right-to-left text.

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `dir` | `"ltr" \| "rtl"` |  |
| `label` | `ReactNode` | An inline visible label before the trigger, when the control is not inside a Field. |
| `name` | `string` |  |
| `onCloseAutoFocus` | `((event: Event) => void)` | Coordinate focus when selecting an option opens another local disclosure. |
| `onValueChange` (required) | `(value: string) => void` |  |
| `options` (required) | `readonly SelectChoice[]` | Immutable choices or groups; replace the array when labels or availability change. |
| `placeholder` | `string` |  |
| `required` | `boolean` |  |
| `value` (required) | `string` |  |
| `variant` | `"outline" \| "ghost" \| "filled"` |  |

## Keyboard

Enter, Space or arrow keys open the list. Arrows move through options; typing jumps to a matching label. Enter or Space selects, and Escape closes and restores focus.

## Works with

[Field](https://unseenui.com/components/field/), [Input](https://unseenui.com/components/input/), [Textarea](https://unseenui.com/components/textarea/), [Checkbox](https://unseenui.com/components/checkbox/), [Switch](https://unseenui.com/components/switch/), [Alert](https://unseenui.com/components/alert/), [Button](https://unseenui.com/components/button/), [RadioGroup](https://unseenui.com/components/radio-group/), [TonePad](https://unseenui.com/components/tone-pad/), [Slider](https://unseenui.com/components/slider/), [InputGroup](https://unseenui.com/components/input-group/), [Combobox](https://unseenui.com/components/combobox/)

Page: https://unseenui.com/components/select/
