Skip to main content

Accordion

A vertical stack of expand/collapse disclosure panels.

Signature
Density
Viewport
Theme and light/dark are set in the top bar
Live demo
Open ↗

When to use​

A vertical stack of expand/collapse disclosure panels.

Accessibility​

Arrow keys move between items; the current item is marked aria-current. Tabs follow the WAI-ARIA tabs pattern (roving tabindex, Home/End).

Install and import​

npx shadcn@latest add @prism/accordion
import { Accordion } from '@/components/prism/Accordion';

In a no-build prototype, read it from the bundle instead: const { Accordion } = window.PrismDesignSystem_39d121;

Props​

PropTypeRequiredDescription
itemsAccordionItem[]Yes
expandedKeysstring[]—Controlled: the ids of the open items. Pair with onExpandedChange.
defaultExpandedKeysstring[]—Uncontrolled: the ids open at first.
onExpandedChange(keys: string[]) => void—Fired with the ids that should be open after a header is pressed.
allowMultipleboolean—Keep multiple panels open at once. Default false (one at a time).
keepMountedboolean—Keep closed panels in the DOM (hidden) so form fields inside them still submit and keep their state. Default true; false unmounts closed panels.
classNamestring—