bx

Select

Displays a list of options for the user to pick from, triggered by a button.

tsx
<Select
  name="fruit"
  placeholder="Select a fruit"
  options={[
    { value: "apple", label: "Apple" },
    { value: "banana", label: "Banana" },
  ]}
/>

Select — dropdown de sélection custom (pas <select> natif). Idéal pour 3-20 options, un seul choix. Au-delà, préférer Combobox (avec search).

Installation

Terminal
$ bext ui add select

Usage

tsx
import { Select } from "@bext-stack/ui/primitives"

// Raccourci avec options prop
<Select
  name="fruit"
  placeholder="Select a fruit"
  options={[
    { value: "apple", label: "Apple" },
    { value: "banana", label: "Banana" },
    { value: "orange", label: "Orange" },
  ]}
/>

Anatomy

<Select name value>
  ├── <SelectTrigger><SelectValue placeholder="…" /></SelectTrigger>
  └── <SelectContent>
      ├── <SelectItem value="a">A</SelectItem>
      └── <SelectItem value="b">B</SelectItem>

API Reference

Select

Prop Type Default Description
name string Nom form.
value string Value sélectionnée.
placeholder string Raccourci — équivalent à passer un SelectValue.
options SelectOption[] Raccourci — génère les SelectItem depuis un array [{value, label}].

SelectTrigger

Prop Type Default Description
children ReactNode Bouton visible avec chevron down.

SelectContent

Prop Type Default Description
children ReactNode Popover avec la liste des items.

SelectItem

Prop Type Default Description
value string undefined
children ReactNode Label affiché.

Data Attributes

Attributs qu'on peut cibler en CSS custom pour override le style par état.

Attribute On Values Description
data-ui="select" root L'island toggle le SelectContent.
data-ui="select-trigger" trigger undefined
data-ui="select-item" item data-value Cliquer sélectionne + ferme.

Keyboard

Key Action
Space / Enter Toggle le popover ; sur item : sélectionne.
Escape Ferme.

Accessibility

Trigger porte role="combobox" aria-haspopup="listbox", liste role="listbox", items role="option".

Try it live
Open in play

Edit this component live in the bext playground. The PRISM + signals version is the bext-native idiom — fine-grained reactivity, no virtual DOM.

src/app/page.tsx 2 files · signals · runs in your browser
Pure PRISM + real bext signals — fine-grained, no re-render.