Rebar UI

1.0

opinion

Select

A closed list of choices.

Project statusNative feel, custom list
Status
Project

84% done

Placeholder
Error

Status is required.

Disabled
Sizes

In context

Filter the boardTwo selects in a filter bar, and the picker on phones
Filter the board
Project
Sort by
Draft launch checklistDue Fri
Research
Icon auditTo do
Design
Harbour homepageIn progress
Design
Brand paletteDone
Design

New task

Project
Status

New task

Project
Status

Status is required.

Native

nativeThe platform's own select (the OS picker on a phone) with the same options and onValueChange. --rebar-select-* tokens style it.

Props

PropTypeRequiredDefault
options(SelectOption | SelectOptionGroup)[]Yes—
valuestring | undefinedNo—
defaultValuestring | undefinedNo—
onValueChange((value: string) => void) | undefinedNo—
placeholderstring | undefinedNo—
disabledboolean | undefinedNo—
size"sm" | "md" | "lg" | undefinedNomd
classNamestring | undefinedNo—
invalidboolean | undefinedNo—
aria-labelstring | undefinedNo—
nativeboolean | undefinedNo—
idstring | undefinedNo—
namestring | undefinedNo—
requiredboolean | undefinedNo—

Accessibility

A real Radix select: the trigger is a <button> with aria-haspopup and aria-expanded, the list a role="listbox". Arrow keys move, typing jumps to a match, Enter picks, Escape closes; a disabled option is announced as such.

data-rebar-* attributes

data-rebar-component="select" on the trigger, with data-rebar-size; .rebar-select-content on the popover.

Migrating to Ant Design

AntD's Select takes options, value and onChange: a close, low-risk rename.

Option groups

options may mix plain options with { label, options: [...] } groups. Each group renders its label as a small uppercase heading (an ARIA group named by it) above its options, with a hairline between groups.

<Select aria-label="Food" options={[{ value: "none", label: "None" }, { label: "Fruit", options: [{ value: "apple", label: "Apple" }] }]} />