Select
Displays a list of options for the user to pick from, triggered by a button.
Apple
Banana
Orange
Grape
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
$ bext ui add select
Copy and paste the following into src/components/ui/select.tsx.
This component is interactive — make sure the shared island is loaded (see Islands). It reacts to data-ui="select" hooks.
Usage
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".
Edit this component live in the bext playground. The PRISM + signals version is the bext-native idiom — fine-grained reactivity, no virtual DOM.
Pure PRISM + real bext signals — fine-grained, no re-render.
The React idiom — same UI, for comparison.
On This Page