# Select ![npm (scoped)](https://img.shields.io/npm/v/@leafygreen-ui/select.svg) #### [View on MongoDB.design](https://www.mongodb.design/component/select/live-example/) ## Installation ### PNPM ```shell pnpm add @leafygreen-ui/select ``` ### Yarn ```shell yarn add @leafygreen-ui/select ``` ### NPM ```shell npm install @leafygreen-ui/select ``` ## Example ### Basic Usage ```js import { Option, OptionGroup, Select, Size } from '@leafygreen-ui/select'; ; ``` ### Typed Values `Select` accepts an optional type parameter (defaulting to `string`) to narrow the type of `value`, `defaultValue`, and the `onChange` callback value: ```tsx type Pet = 'dog' | 'cat' | ''; const [value, setValue] = useState(''); label="Pet" value={value} onChange={setValue}> ; ``` Note: when `allowDeselect` is enabled (default), deselecting calls `onChange` with `''` — include `''` in the union (as above) or set `allowDeselect={false}`. Note: the type parameter narrows `value`, `defaultValue`, and `onChange` only — `Option` values are not checked against it (`