Skip to main content

Select

A dropdown for choosing one value from a list, built on Radix UI's Select primitive. Options can be flat or grouped.

import { Select } from '@jbpark/ui-kit';

<Select
placeholder="Choose a framework"
options={[
{ label: 'React', value: 'react' },
{ label: 'Vue', value: 'vue' },
]}
onChange={value => console.log(value)}
/>;
Selected: none

Props

PropTypeDefault
options(Option | OptionGroup)[]-
placeholderstring-
onChange(value: string) => void-
classNamestring-
interface Option {
label: React.ReactNode;
value: string;
}

interface OptionGroup {
label: React.ReactNode;
options: Option[];
}

An OptionGroup entry (an options array instead of value) renders as a labeled group. Select also accepts the rest of Radix UI's Select root props (e.g. value, defaultValue, disabled, name, required) except onValueChange, which is renamed to onChange above.