packages/insomnia-component-docs/docs/Components/select.mdx
A customizable dropdown select component built on top of React Aria Components, providing accessible single-selection functionality with keyboard navigation and visual states.
| Prop | Type | Required | Description |
|---|---|---|---|
options | { label: string; value: string }[] | Yes | Array of selectable options |
value | string | number | null | No | Currently selected value (controlled) |
onChange | (key: string | number | null) => void | No | Callback fired when selection changes |
label | string | No | Label for the select (currently unused in implementation) |
className | string | No | Additional CSS classes for the select |
<Select
options={[
{ label: 'Option 1', value: 'opt1' },
{ label: 'Option 2', value: 'opt2' },
{ label: 'Option 3', value: 'opt3' },
]}
/>
<Select isDisabled />
function DisabledOption() {
const [selected, setSelected] = useState<string | null>(null);
return (
<Select
onChange={setSelected}
value={selected}
disabledKeys={['B']}
options={[
{ label: 'A', value: 'A' },
{ label: 'BBBBBB', value: 'B' },
{ label: 'CCCCCC', value: 'C' },
]}
/>
);
}
The component uses the following CSS variables for theming:
--color-bg: Select background color--color-font: Select text color--hl-xs: Highlight for hover/active--hl-sm: Standard border color--color-danger: Error/invalid state colorYou can customize these variables in your CSS to theme the select appearance.