Select v0.1.0 Forms

Single-select listbox (combobox pattern): typeahead, disabled-item skipping, keyboard navigation, anchored positioning.

import { Select } from "latticeui-react";

Examples

Basic

Full listbox keyboard support: arrows, Home/End, and typeahead.

Framework
value: null
Show code
<Select
  label="Framework"
  placeholder="Pick a framework"
  items={[
    { value: "react", label: "React" },
    { value: "vue", label: "Vue" },
    { value: "svelte", label: "Svelte" },
    { value: "angular", label: "Angular", disabled: true },
  ]}
  onValueChange={setValue}
/>

Anatomy

These data-part attributes are a versioned public API - style and test against them; they will not change in a minor release.

PartElementStable selector
rootdiv[data-scope="select"][data-part="root"]
labelspan[data-scope="select"][data-part="label"]
triggerbutton[role=combobox][data-scope="select"][data-part="trigger"]
valuespan[data-scope="select"][data-part="value"]
indicatorspan[data-scope="select"][data-part="indicator"]
positionerdiv[data-scope="select"][data-part="positioner"]
contentul[role=listbox][data-scope="select"][data-part="content"]
itemli[role=option][data-scope="select"][data-part="item"]
itemTextspan[data-scope="select"][data-part="itemText"]
itemIndicatorspan[data-scope="select"][data-part="itemIndicator"]

Props

PropTypeDefaultDescription
items *{ value: string; label: string; disabled?: boolean }[]
labelstring
placeholderstring"Select an option"
value / defaultValuestring | null
onValueChange(value: string | null) => void
disabledboolean

Accessibility

Roles: combobox triggerlistboxoption

KeyAction
ArrowDown/ArrowUpopens / moves highlight
Enter / Spaceselects highlighted option
Home/Endfirst/last option
printable charstypeahead
Escapecloses

Styling

Override styles by targeting the stable selectors below from any unlayered CSS - it always beats the library's @layer latticeui styles, no !important needed.

[data-scope="select"][data-part="item"] {
  /* your overrides */
}

State attributes: data-state=open|closed (trigger)data-highlighteddata-placeholder