structyl

Accordion

stable

A vertically stacked set of interactive headings that each reveal a section of content.

Basic usage

Examples

Multiple panels

Allow several panels to be open simultaneously.

Multiple open panels

Use type="multiple" for FAQ and settings pages where several sections can stay open.

Invoices, payment methods and tax details.

Two-factor authentication and audit logs.

Features

  • Full keyboard navigation.
  • Supports single or multiple expanded panels.
  • Can be controlled or uncontrolled.
  • Spring-eased height animation.

Installation

bash
pnpm dlx structyl add accordion

API Reference

Accordion.Root

Contains all accordion items.

PropTypeDefault
type'single' | 'multiple'

Whether one or many panels can be open.

valuestring | string[]

Controlled open item(s).

defaultValuestring | string[]

Initial open item(s).

onValueChange(value) => void

Called when the open set changes.

collapsibleboolean

For type='single', allow closing the open item.

false
disabledboolean

Disable the whole accordion.

false

Accordion.Item

A single collapsible section.

PropTypeDefault
valuestring

Unique value identifying the item.

disabledboolean

Disable this item.

false

Accordion.Trigger

Toggles its panel. Wrapped in a Header.

PropTypeDefault

Accordion.Content

The collapsible panel content.

PropTypeDefault
forceMountboolean

Force mounting for animation control.

Keyboard interactions

Adheres to the WAI-ARIA design pattern .

KeyDescription
Space / EnterExpands / collapses the focused panel.
ArrowDown / ArrowUpMoves focus between headers.
Home / EndMoves focus to the first / last header.
Accordion | structyl