Introducing PrimeReact v11-alpha 🎉Discover Now

Accordion

Accordion groups content into collapsible panels.

preview

Installation#

npx shadcn@latest add @primereact/accordion

Usage#

import { Accordion, AccordionContent, AccordionPanel, AccordionTrigger } from '@/components/ui/accordion';
<Accordion>
    <AccordionPanel value="1">
        <AccordionTrigger>Title</AccordionTrigger>
        <AccordionContent>Content</AccordionContent>
    </AccordionPanel>
</Accordion>

Examples#

Basic#

basic-demo

Multiple#

Each Accordion.Panel should define a unique value. By default, a single panel is open at a time. Enable multiple on Accordion.Root to allow multiple panels to stay open.

multiple-demo

Controlled#

Control the active panel state with value and onValueChange.

This service helps you manage your projects more efficiently by offering real-time collaboration, task tracking, and powerful analytics.

controlled-demo

Disabled#

Set disabled on an Accordion.Panel to disable only that panel, or set it on Accordion.Root to disable all panels.

disabled-demo

With RadioButton#

RadioButton component can be used to group multiple Accordion.Panel components.

Perfect for individuals getting started. Includes access to core components and community support.

with-radiobutton-demo

Accessibility#

Screen Reader#

Accordion headers are buttons. They use aria-controls to reference the content region and aria-expanded to reflect visibility state. The announced label can be customized with aria-label or aria-labelledby via pt.

The content uses role="region" and an id that matches the header button's aria-controls.

Header Keyboard Support#

KeyFunction
tabMoves focus to the next focusable element in the page tab sequence.
shift + tabMoves focus to the previous focusable element in the page tab sequence.
enterToggles the visibility of the content.
spaceToggles the visibility of the content.
down arrowMoves focus to the next header. If focus is on the last header, moves focus to the first header.
up arrowMoves focus to the previous header. If focus is on the first header, moves focus to the last header.
homeMoves focus to the first header.
endMoves focus to the last header.