Skip to content

Now in the official shadcn registry directory.

Start free

Select

A dropdown for picking one value from a list - grouped items, labels, separators and scroll buttons, with a popper-positioned content panel.

form
A free styled version is available

Installation

Run the following command

npx shadcn@latest add @ai2/select

Dependencies, the @ai2/tokens theme and the component file are installed together.

Usage

TS
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select"

<Select>
  <SelectTrigger className="w-56">
    <SelectValue placeholder="Select a region" />
  </SelectTrigger>
  <SelectContent>
    <SelectItem value="iad">us-east-1 · Virginia</SelectItem>
    <SelectItem value="sfo">us-west-2 · Oregon</SelectItem>
  </SelectContent>
</Select>

The trigger is w-fit by default - give it a width class to keep it stable while the value changes. The content panel matches the trigger width automatically.

Examples

Trigger sizes

Trigger variants

Trigger tones

tone colors the border and focus ring for validation states, matching the ai2 Input and Textarea.

Groups and separators

Disabled

disabled on the root disables the whole select; on an item it grays out that option and skips it in keyboard navigation.

Invalid

Set aria-invalid on the trigger when validation fails. The danger border and ring style is built in and matches every other ai2 form control.

Props

SelectTrigger carries the ai2-specific props. Every part also accepts its radix props - value, defaultValue and onValueChange on the root included.

SelectTrigger props

PropTypeDefaultDescription
variant"outline" | "soft" | "ghost""outline"Visual style of the trigger: bordered, filled or transparent.
size"sm" | "md" | "lg""md"Height of the trigger: 32, 36 or 40px.
tone"neutral" | "success" | "danger""neutral"Validation look: colors the trigger border and focus ring.

ai2 Select: a dropdown picker for React, built on radix-ui

The ai2 Select is a shadcn-compatible select component for React, built on the radix-ui Select primitive and styled with Tailwind CSS v4. It replaces the native select with a fully styled trigger and a popper-positioned panel that supports groups, labels, separators, scroll buttons for long lists and a check indicator on the selected item.

Because it ships through the shadcn registry format, you install it with one CLI command, an MCP agent, or a copy-paste, and the source lands in your own project. You own the file; there is no runtime dependency on ai2 itself. The live example above is the exact component you get.

What is the ai2 Select?

The core anatomy is Select, SelectTrigger, SelectValue, SelectContent and SelectItem, extended by SelectGroup, SelectLabel, SelectSeparator and the two scroll buttons. It matches shadcn/ui exactly, so existing snippets, muscle memory and AI agents keep working without changes.

The trigger carries the ai2-specific props from the shared input contract: a variant of outline, soft or ghost, a size of sm, md or lg (32, 36 or 40 pixels tall) and a tone of neutral, success or danger that colors the border and focus ring for validation states. The content renders in a portal with popper positioning, matches the trigger width, and caps its height to the space available in the viewport.

Why use it

  • Accessible by construction: The radix-ui Select primitive handles roles, state, focus and full keyboard support: arrow keys move through items, Enter selects, Escape closes and typing jumps to matching options.
  • Scroll buttons for long lists: The panel height is capped to the available viewport space, and chevron scroll buttons appear at the top and bottom whenever the list overflows.
  • Visible selection: The selected item shows a check icon in a reserved slot on the right, so the current value is obvious even in long grouped lists.
  • Trigger-matched panel width: With the default popper positioning the content matches the trigger width automatically, so the closed and open states always line up.
  • Agent-readable metadata: The registry item describes its parts and intended use in plain words, so an MCP agent can find, inspect and install it without guessing.

Features

  • shadcn registry install: One command adds the component, its dependencies and the @ai2/tokens theme to your project.
  • 3 variants, 3 sizes and 3 tones: The trigger offers outline, soft and ghost variants, sm, md and lg heights of 32, 36 and 40 pixels, and neutral, success and danger tones, aligned with the ai2 Input contract.
  • Groups, labels and separators: SelectGroup, SelectLabel and SelectSeparator structure long option lists, like regions grouped by continent in the example above.
  • Portal and popper positioning: The panel renders in a portal, escapes overflow-hidden parents, and animates open and close with a fade and zoom tied to data-state.
  • Placeholder and invalid styling: The trigger mutes placeholder text through data-placeholder, shows the ai2 focus-visible ring, and switches to the danger border and ring under aria-invalid.
  • TypeScript source: Every part is typed end to end and forwards its radix props, including value, defaultValue and onValueChange on the root.

Production tips

  • Fix the trigger width: The trigger is w-fit by default and would resize as the value changes. Give it a width class, like w-56, so the layout stays stable.
  • Group anything past a handful: Once a list passes seven or eight options, SelectGroup with a SelectLabel per section makes scanning dramatically faster than one flat list.
  • Lead item text with the keyword: Typeahead matches what users type against the item text, so start options with the word people think of first, like the region name rather than a code.
  • Disable at the right level: disabled on the root grays out the whole control; disabled on a single item keeps it visible but unselectable and skipped by keyboard navigation.
  • Know when you need a combobox: Select is single-value and filter-free by design. When users need to search within many options, reach for the ai2 Combobox instead of stuffing a filter into the panel.

Works with the rest of ai2

The select composes naturally with the rest of the registry. Pair it with an ai2 Label for the accessible name, or drop it into an ai2 Field to pick up descriptions and validation messages alongside other form controls.

For neighboring pickers, the ai2 Combobox adds text filtering for long lists, the ai2 Dropdown Menu covers actions rather than values, and the ai2 Radio Group keeps two to five options always visible. Everything shares one token source, so combinations stay visually consistent in both modes.

FAQs

Get new components in your inbox

Component drops, new themes and release notes. No spam, and you can unsubscribe from any email.

© 2026 ai2 design system · MIT licensed · Built with its own components