Skip to content

Select

A select on Base UI Select.

Pass items to Select so the trigger shows an option's label, not its value.

With a label

Sizes

With groups

Below the trigger

Disabled

With a disabled option

Invalid

Installation

npx shadcn@latest add @khaeli/select

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

Registry items
npm packages
  • @base-ui/react ^1.7.0
  • @keyline-icons/react ^2.2.0

Keyboard

EnterSpaceArrowDownArrowUp
On the trigger, open the list. Focus lands on the chosen option, or on the first one.
ArrowDownArrowUp
Move through the options. A disabled option can be reached but not chosen.
HomeEnd
Move to the first and to the last option.
A to Z
In the list, moves to the option that starts with the letters typed. On the closed trigger, chooses it without opening the list.
EnterSpace
On an option, choose it and close the list. Focus returns to the trigger.
Escape
Closes the list and keeps the value. Focus returns to the trigger.
Tab
Closes the list and moves focus on.

Accessible name

  • The trigger is a button with role="combobox". Give SelectTrigger an id and point a @khaeli/label at it with htmlFor, or give it an aria-label.
  • The chosen option's label is read as the trigger's value, so the name is the question, not the answer: Status, not In progress.
  • SelectLabel names a SelectGroup.
  • For an invalid select, put aria-invalid and aria-describedby on SelectTrigger.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/select.json