Accordion
A vertically stacked set of interactive headings that each reveal a section of content.
Accordion — pile de sections expansibles. type="single" ferme les autres quand tu ouvres une (défaut), type="multiple" laisse plusieurs ouvertes.
Installation
$ bext ui add accordion
Copy and paste the following into src/components/ui/accordion.tsx.
This component is interactive — make sure the shared island is loaded (see Islands). It reacts to data-ui="accordion" hooks.
Usage
Anatomy
<Accordion type="single" collapsible> ├── <AccordionItem value="q1"> │ ├── <AccordionTrigger>Question 1</AccordionTrigger> │ └── <AccordionContent>Réponse 1</AccordionContent> └── <AccordionItem value="q2">...</AccordionItem> </Accordion>
API Reference
Accordion
| Prop | Type | Default | Description |
|---|---|---|---|
| type | "single" | "multiple" | "single" | undefined |
| collapsible | boolean | — | Si single : autorise à refermer l'item ouvert. |
| defaultValue | string | string[] | — | undefined |
AccordionItem
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | — | undefined |
| children | ReactNode | — | undefined |
AccordionTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | Chevron intégré, rotate 180° quand ouvert. |
AccordionContent
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | undefined |
Data Attributes
Attributs qu'on peut cibler en CSS custom pour override le style par état.
| Attribute | On | Values | Description |
|---|---|---|---|
| data-ui="accordion" | Accordion root | undefined | undefined |
| data-state | AccordionItem | "open" | "closed" | undefined |
Keyboard
| Key | Action |
|---|---|
| Space / Enter | Ouvrir/fermer le trigger focus. |
| Arrow Up / Down | Naviguer entre triggers. |
Accessibility
Chaque trigger est un <button aria-expanded aria-controls>, chaque content porte role="region" aria-labelledby.
Edit this component live in the bext playground. The PRISM + signals version is the bext-native idiom — fine-grained reactivity, no virtual DOM.
On This Page