4.2.0
Core

Select

One choice from a list long enough that showing every option would cost more than hiding them.

Default

The trigger always holds a `SelectValue`, and the placeholder belongs on that: the value is what echoes the choice once one is made, so it is also what has to speak before one exists. Label it the way any other field is labelled — the trigger is a button, and a button is not a label.

Usage

import {
  Select,
  SelectContent,
  SelectGroup,
  SelectItem,
  SelectLabel,
  SelectScrollDownButton,
  SelectScrollUpButton,
  SelectSeparator,
  SelectTrigger,
  SelectValue,
} from '@oceanic-hub/brand-system'
<Select>
  <SelectTrigger>
    <SelectValue>…</SelectValue>
  </SelectTrigger>
  <SelectContent>
    <SelectItem value="…">…</SelectItem>
  </SelectContent>
</Select>

Composition

Use the following composition to build a Select:

Select
├── SelectTrigger
│   └── SelectValue
└── SelectContent
    ├── SelectItem ×4
    ├── SelectGroup ×3
    │   ├── SelectLabel
    │   └── SelectItem ×2
    └── SelectSeparator ×2

Reach for it above roughly seven options, where RadioGroup stops being scannable, and below the point where a reader would rather type than scroll — past a screenful or two the answer is the Combobox recipe (Popover + Command), because only that one can filter. NativeSelect is the other neighbour, and the test between them is what the OPEN state has to show: nothing to style means the platform's own picker is the better control; a check mark, an icon or a grouped list means this one.

SelectTrigger always contains a SelectValue, and the placeholder belongs on that rather than on the trigger — the value is the element that echoes the choice, so it is also the one that has to speak before a choice exists. A SelectItem's value is its IDENTITY, not its label, so it must never be the index or a display string somebody might translate later. An item whose children are not plain text also wants textValue, or keyboard typeahead has nothing to match.

SelectContent portals itself, which is why a select inside a table cell or a drawer is never clipped — and why rendering the list inline is not reachable through this API. It also defaults position to popper rather than Radix's own item-aligned, so the trigger stays readable while the list is open; the other mode gets its own section below.

Invalid is a solid stuck border, and it is stated twice. aria-invalid on the control paints it — that is the attribute assistive technology already reads — and a Field marked data-invalid paints it too, so a surface that wires only one of the two still draws the line (@OCE-1877). Neither is the whole message: FieldError carries the sentence, in ink beside a stuck mark, because a border can say that something is wrong and never what. Field's page shows the line drawn on every control at once.

RTL is not supported — recorded in pairings.json under direction: nothing in this package has been laid out or measured right-to-left, and upstream ships an RTL example.

Groups

SelectGroup + SelectLabel name a section of the list, and SelectSeparator sets a hairline between two of them. Reach for grouping once a reader scans for a category before an option — regions by continent, environments by stage. The label is what does the work and the rule is deliberately quiet, so a group of one is furniture: if only one section needs a heading, none of them do.

Aligned to the selected item

position="item-aligned" opens the list over the trigger with the chosen row under the pointer, instead of anchoring it below. Reach for it when the list is long and the current value is where the reader wants to start — a hundred timezones, a version history. It costs the trigger, which the list now covers, so it is wrong for a short field whose label was carrying the question. Upstream reaches the same behaviour through alignItemWithTrigger; here it is position, and the default is the anchored popper.

Scrollable

Past the list's own height the panel scrolls and grows SelectScrollUpButton and SelectScrollDownButton at its edges — nothing to compose, but the parts are exported because a caller building a bespoke content node still needs them. Treat a list this long as a signal rather than a feature: once scrolling is how the option is found, the reader wanted to type, and that is the Combobox recipe.

Disabled

disabled on the root makes the whole control inert and fades it, for a field whose answer is determined by something else on the page — a currency fixed by the billing account, a plan set by the owner. Keep the chosen value showing rather than the placeholder: a disabled field that also says nothing tells the reader neither what the answer is nor that they are not choosing it.

Fixed when the billing account was created.

Unavailable options

disabled on a SelectItem keeps an option in the list and out of reach — right when the reader ought to know it exists, like a region their plan does not include. Drop the item entirely when its absence needs no explanation; a list of rows nobody can pick is a pricing page in disguise, and the option's own label has to carry the reason because the row cannot be hovered for a tooltip.

API Reference

See the Select API page for every prop of every part, with types, defaults and the contract that pins them.

On this page