Accordion
Stacks sections under headings that open on demand, for long content read in parts.
When to use
- Long content read in parts, where users open only the sections they need: FAQs, reference notes, grouped settings.
- A page that would be too long with every section open.
When not to use
- One section that shows and hides: use Collapsible.
- Views of the same subject that users switch between: use Tabs.
- Content everyone must read, such as a consent notice: keep it open on the page, in a Card.
Install
npx shadcn@latest add @clinia/accordionA design system built on Tailwind v4 and Base UI, encoding Clinia's brand guidelines into reusable components.
Anatomy
Records stay in the region you picked when you created the workspace.
- 1Container
data-slot="accordion"border · rounded-lg - 2Trigger
[data-part=trigger-text]text-sm · font-medium - 3Chevron
[data-slot=accordion-trigger] > svg:not(.hidden)size-4 · text-muted-foreground - 4Panel
data-slot="accordion-content"text-sm · px-4 pb-4
Clinia rules
- Trigger text is
text-sm font-medium, sentence case, and names the question or topic a reader scans for:How do I rotate an API key?, notMore. - An open item's chevron points up. The chevron carries the state, with no tint behind the item.
- One item opens at a time. Set
multiplewhen users need to compare sections side by side. - Don't nest an accordion inside another. Split the content into two accordions under their own headings.
Do and don't
States
closed
open
Synced every night at 2 a.m.
hover
focus
disabled
Focus cells apply the component's focus-visible classes statically. Toggle the site theme to review both themes.
Accessibility
Built in
- Each trigger is a
buttoninside anh3, witharia-expandedandaria-controlspointing at its panel. - Enter or Space toggles the focused trigger. Tab moves from one trigger to the next.
Your responsibility
- Keep the trigger text short and specific: screen reader users jump between the headings to find a section.
- Set
hiddenUntilFoundonAccordionContentfor reference content, so the browser's find-in-page reaches text in closed panels. - Never put the only copy of a required step or a warning in a closed panel.
How to test
- Press Tab until a trigger has focus, then Tab again: focus moves to the next trigger.
- Press Enter, then Space: the panel opens, then closes, and the chevron flips each time.
- With a screen reader, a trigger is announced as its text, a button, and collapsed or expanded, inside a level 3 heading.
API
Every prop comes from Base UI Accordion.
Related