Page:
Accordion
Pages
Accordion
AccordionItem
Alert
Avatar
Badge
BarChart
Button
ButtonGroup
Card
Changelog
ChartLegend
Checkbox
CodeEditor
Collapsible
Combobox
CommandPalette
ContextMenu
CopyButton
DatePicker
Dialog
DonutChart
Drawer
Field
FileInput
FileList
Forms
Gauge
Getting started
Heatmap
Home
Image
InlineEdit
Input
Kbd
Label
LineChart
Menu
MultiSelect
NumberInput
Overlays
Pagination
Popover
Progress
RadioGroup
Scroller
Select
Separator
ShareBar
Sheet
Skeleton
Slider
Sparkline
Spinner
StatCard
Switch
Table
Tabs
TagsInput
Textarea
Theming
Toaster
Toggle
Tooltip
Tree
No results
2
Accordion
L4stIdi0t edited this page 2026-09-08 22:50:57 +02:00
Accordion
A set of disclosure sections.
type="single" keeps one open at a time, "multiple" lets them stack; defaultValue seeds which start open. The open state lives here and reaches the items through context.
Layout · keyboard contract
<script lang="ts">
import { Accordion } from '@l4st/driftwood';
</script>
| Light | Dark |
|---|---|
![]() |
![]() |
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
type |
'single' | 'multiple' |
'single' |
'single' = one item open at a time; 'multiple' = independent. |
defaultValue |
string | string[] |
— | Item value(s) open on first render — the section a page wants to lead with. Uncontrolled: it seeds the state and the user takes it from there. |
class |
string |
— | Merged with the component's own classes, last — so yours win. |
children required |
Snippet |
— | The content. |
Types
export type AccordionContext = {
isOpen: (value: string) => boolean;
toggle: (value: string) => void;
};
Keyboard
| Key | Does |
|---|---|
| Enter / Space | toggle the focused section |
Example
The markup behind the screenshot above, lifted from src/routes/shots/ — so it
compiles, and it is exactly what produced the image.
<Accordion type="single" defaultValue="deps">
<AccordionItem value="deps" title="What does driftwood depend on?">
clsx and tailwind-merge, for cn(). Nothing else.
</AccordionItem>
<AccordionItem value="theme" title="How do I re-theme it?">
Redefine the CSS custom properties in your own stylesheet.
</AccordionItem>
</Accordion>
Layout · Card · StatCard · AccordionItem · Collapsible · Separator · Table · Scroller
driftwood
Layout
Actions
Forms
- Field
- Input
- FileInput
- FileList
- Textarea
- CodeEditor
- Combobox
- RadioGroup
- NumberInput
- InlineEdit
- Label
- Select
- MultiSelect
- DatePicker
- TagsInput
- Checkbox
- Switch
- Slider
Feedback
Charts
Overlays
Navigation
Generated from the source by pnpm wiki · repository · v0.24.0

