Skip to content

Select

A styled select dropdown with keyboard navigation.

Installation

import { Select } from '@smc/darwin-ui';

Usage

import { Select } from '@smc/darwin-ui';
const options = [
{ value: 'option1', label: 'Option 1' },
{ value: 'option2', label: 'Option 2' },
{ value: 'option3', label: 'Option 3' },
];
export function Example() {
const [value, setValue] = useState('');
return (
<Select
options={options}
value={value}
onChange={setValue}
placeholder="Select an option"
/>
);
}

API Reference

Props

PropTypeDefaultDescription
optionsOption[]-Available options
valuestring-Selected value
onChange(value: string) => void-Change handler
placeholderstring-Placeholder text
disabledbooleanfalseDisable select

Option Type

interface Option {
value: string;
label: string;
}