1. Documentation
  2. Forms
  3. Select
ReadmenpmGitHub
  • Introduction
  • Installation
  • Theming
  • Icons
  • Accordion
  • Card
  • Scroll Area
  • Separator
  • Sidebar
  • Field
  • Label
  • Input
  • Textarea
  • Number Field
  • OTP Field
  • Select
  • Combobox
  • Checkbox
  • Radio
  • Switch
  • Slider
  • Toggle
  • Calendar
  • Date Picker
  • File Upload
  • Button
  • Copy Button
  • Dropdown
  • Command
  • Tabs
  • Breadcrumb
  • Pagination
  • Tree
  • Table
  • Data Table
  • Stat
  • Timeline
  • Avatar
  • Status Bar
  • Badge
  • Meter
  • Empty
  • Skeleton
  • Spinner
  • Toast
  • Dialog
  • Sheet
  • Popover
  • Tooltip
  • Text
  • Kbd
  • Code Block
  • Utilities
  • Design rules

Select

A single-choice dropdown with sticky group labels — composed, or built from data in one line.

Loading documentation…

OTP Field< PreviousComboboxNext >

Powered by heyo

On this page

UsageFrom dataSizes and a fieldMultiple valuesPropertiesSelectSelect.TriggerSelect.ContentItems and groups
<Select defaultValue="fra"><Select.Trigger placeholder="Pick a region" /><Select.Content>  <Select.Group>    <Select.GroupLabel>Europe</Select.GroupLabel>    <Select.Item value="fra">Frankfurt</Select.Item>    <Select.Item value="waw">Warsaw</Select.Item>  </Select.Group>  <Select.Group>    <Select.GroupLabel>North America</Select.GroupLabel>    <Select.Item value="iad">Ashburn</Select.Item>  </Select.Group></Select.Content></Select>

Select picks one value from a known list. Groups rule themselves off and their labels stick while you scroll, so a long list never loses its headings. The popup caps at 18rem — or the space available, whichever is smaller — and scrolls past that.

It does not lock the page. modal defaults to false, unlike Base UI: picking a value from a list is not a modal task, and freezing the application behind one is both surprising and, if the unlock ever misses, permanent.

Usage

tsx
import { Select } from "@heyo-sh/heyo-ui";<Select defaultValue="fra" onValueChange={setRegion}>  <Select.Trigger placeholder="Pick a region" />  <Select.Content items={regions} /></Select>;

From data

items builds the list, and a nested items array becomes a titled group — the same markup the example above writes by hand.

<Select><Select.Trigger placeholder="Pick a region" /><Select.Content  items={[    { label: "Europe", items: [      { value: "fra", label: "Frankfurt" },      { value: "waw", label: "Warsaw" },    ] },    { value: "iad", label: "Ashburn" },  ]}/></Select>

Sizes and a field

The trigger takes the four control heights, and the whole thing drops into a Field when it needs a label.

Where the deploy lands.

<Field label="Environment" description="Where the deploy lands."><Select defaultValue="prod">  <Select.Trigger />  <Select.Content items={[    { value: "prod", label: "Production" },    { value: "staging", label: "Staging" },  ]} /></Select></Field><Select defaultValue="24h"><Select.Trigger size="sm" /><Select.Content items={[{ value: "24h", label: "Last 24 hours" }]} /></Select>

Multiple values

Pass multiple and the value becomes an array. For more than a handful of options — or anything worth typing to find — use Combobox instead.

<Select multiple defaultValue={["fra", "waw"]}><Select.Trigger placeholder="Pick regions" /><Select.Content items={regions} /></Select>

Properties

Select

value / defaultValueValueoptional

Controlled and uncontrolled selection. With multiple, both are arrays.

onValueChange(value: Value) => voidoptional

Fires when the selection changes.

multiplebooleanoptional

Allows several values.

modalbooleanoptional

Whether the open list locks the page. It defaults to false, unlike Base UI.

disabled / required / name—optional

Standard form behaviour, passed through to Base UI.

Select.Trigger

placeholderstringoptional

Shown when nothing is selected.

size"xs" | "sm" | "base" | "lg"optional

Control height. It defaults to base.

childrenReactNodeoptional

Replaces the rendered value — pass Select.Value with a renderer for anything custom.

Select.Content

itemsSelectOption[]optional

Shorthand. An entry is { value, label, disabled }, or { label, items } for a titled group.

maxHeightstringoptional

Cap on the popup height. It defaults to 18rem; anything taller scrolls.

sideOffsetnumberoptional

Gap between the trigger and the popup.

positionerSelect.Positioner.Propsoptional

Placement overrides.

Items and groups

Select.Itemvalue, disabledoptional

One option. The check mark is drawn for you.

Select.Group / GroupLabel—optional

A titled section. It draws its own top rule, so consecutive groups separate themselves — no manual Select.Separator between them.

Select.Separator—optional

A rule, for the rare case a group is not what you want.

Select.Valuechildrenoptional

The rendered value inside the trigger, when you need to format it.