# Select

> The everyday select, sized to sit flush beside a text field: label, hint, description and error, a placeholder, a leading icon, labelled groups with separators, a quiet second line per option, disabled options and three sizes. The popup can open over the trigger with the picked option on the value, and typeahead, Home/End and Escape come from Base UI.

- Slug: `select`
- Category: [Selects](https://www.assembli.design/category/selects.md)
- Type: component
- Tags: select, dropdown, listbox, form, groups, keyboard
- npm dependencies: @base-ui/react, lucide-react
- shadcn/ui dependencies: none
- Live preview: https://www.assembli.design/preview/select
- Page: https://www.assembli.design/components/select

![Select preview](https://www.assembli.design/thumbnails/select-light.png)

## Props

Other props pass through to the root element.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `options` (required) | `(SelectOption \| SelectOptionGroup)[]` |  | Options, groups of options, or a mix. Consecutive loose options share an unlabelled group. |
| `value` | `string \| null` |  |  |
| `defaultValue` | `string \| null` | `null` |  |
| `onValueChange` | `(value: string \| null) => void` |  |  |
| `label` | `React.ReactNode` |  |  |
| `hint` | `React.ReactNode` |  | Quiet text to the right of the label, such as "Optional". |
| `description` | `React.ReactNode` |  |  |
| `error` | `React.ReactNode` |  | Replaces the description and marks the trigger `aria-invalid`. |
| `placeholder` | `React.ReactNode` | `"Select…"` |  |
| `leading` | `React.ReactNode` |  | A field icon before the value. A picked option's own icon takes its place. |
| `size` | `SelectSize` | `"md"` |  |
| `disabled` | `boolean` |  |  |
| `required` | `boolean` |  |  |
| `name` | `string` |  | Submits the value with a surrounding form. |
| `alignItemWithTrigger` | `boolean` | `true` | Opens the popup over the trigger with the picked option sitting on the value, like a native macOS menu (mouse only; touch and tight spaces fall back to dropping below). Set `false` to always drop bel… |
| `open` | `boolean` |  |  |
| `defaultOpen` | `boolean` |  |  |
| `onOpenChange` | `(open: boolean) => void` |  |  |
| `modal` | `boolean` |  | Locks page scroll and outside clicks while open. Defaults to `true`. |
| `triggerClassName` | `string` |  | Classes for the trigger; `className` goes on the root. |

## Install

One-time setup (needs a subscription):

1. Add the registry to the project's `components.json`: `{"@assembli":{"url":"https://www.assembli.design/r/{name}.json","headers":{"Authorization":"Bearer ${ASSEMBLI_API_KEY}"}}}` (merge into `"registries"`).
2. Put an API key from https://www.assembli.design/account in `.env.local` as `ASSEMBLI_API_KEY=asm_…`.

Then install with the shadcn CLI (writes `components/select/select.tsx` and installs dependencies):

```bash
npx shadcn@latest add @assembli/select
```

Registry item JSON: https://www.assembli.design/r/select.json (send `Authorization: Bearer <api key>`)

## Code

> Component source needs an Assembli subscription ($12/month or $96/year) and an API key sent as `Authorization: Bearer <key>`. To get one without copying anything, POST https://www.assembli.design/api/agent/login (or call the MCP tool connect_account), show the user the link it returns, and poll https://www.assembli.design/api/agent/token for the key. Or subscribe at https://www.assembli.design/pricing and create a key at https://www.assembli.design/account.
