This page as markdown: /accordion.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

Accordion

Status: stable

Stacked, collapsible disclosure sections over Base UI Accordion — roving focus, arrow-key navigation, ARIA region/heading/button wiring, and an animated height transition. Each item pairs a full-width trigger (with a rotating chevron) and a panel.

Keywords: accordion, disclosure, collapse, faq

Usage

Use Accordion to reveal a vertical set of related sections while keeping the surrounding page scannable.

Best practices

Anatomy

Part Required Description
AccordionItem yes One expandable section in the group.
AccordionTrigger yes The button-like control that opens the section.
AccordionPanel yes The content revealed by the trigger.

Subcomponents

Name Type Description
AccordionItem Base UI Accordion.Item props + className (value, disabled, onOpenChange) Pairs a header with its panel. Give each a stable value to control or set initial open state.
AccordionTrigger Base UI Accordion.Trigger props + className + indicator?: ReactNode + headingLevel?: 2 | 3 | 4 | 5 | 6 (default 3) The header button (Header + Trigger composed). Renders children plus a chevron that rotates via data-[panel-open] by default; pass indicator to replace the icon and its open-state behavior entirely (e.g. a plus that becomes an × for a FAQ-style toggle). headingLevel sets the heading that wraps the button so the accordion fits the page outline: h2 for an FAQ directly under the page title, h4 under an h3 section. Defaults to h3.
AccordionPanel Base UI Accordion.Panel props + className (keepMounted, hiddenUntilFound) The collapsible body. Animates height using the --accordion-panel-height CSS var; fades on data-[starting-style]/data-[ending-style].

Props

Name Type Default Description
Accordion (Root) Base UI Accordion.Root props (value, defaultValue, multiple, disabled, onValueChange, orientation, loopFocus, keepMounted, hiddenUntilFound) — Groups all items and owns the open value(s). Uncontrolled via defaultValue, controlled via value.
defaultValue Value[] [] Uncontrolled set of item values that start expanded (e.g. ['faq-1']).
value Value[] — Controlled set of expanded item values; pair with onValueChange.
onValueChange (value: Value[]) => void — Called with the new set of expanded item values when an item opens or closes.
multiple boolean false Whether more than one item can be open at the same time. When false, opening one closes the others.

Tokens used

border, foreground, muted-foreground, ring

Motion

Accessibility

Related

Examples

Single (default)

import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger } from "@sableui/react"

<Accordion defaultValue={["a"]}><AccordionItem value="a"><AccordionTrigger>Can I cancel anytime?</AccordionTrigger><AccordionPanel>Yes — from billing settings.</AccordionPanel></AccordionItem><AccordionItem value="b"><AccordionTrigger>How much?</AccordionTrigger><AccordionPanel>$16 per seat each month.</AccordionPanel></AccordionItem></Accordion>

Multiple open

import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger } from "@sableui/react"

<Accordion multiple defaultValue={["a", "b"]}><AccordionItem value="a"><AccordionTrigger>First</AccordionTrigger><AccordionPanel>One.</AccordionPanel></AccordionItem><AccordionItem value="b"><AccordionTrigger>Second</AccordionTrigger><AccordionPanel>Two.</AccordionPanel></AccordionItem></Accordion>

Heading level

import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger } from "@sableui/react"

<Accordion><AccordionItem value="a"><AccordionTrigger headingLevel={2}>Can I cancel anytime?</AccordionTrigger><AccordionPanel>Yes — from billing settings.</AccordionPanel></AccordionItem></Accordion>

Custom indicator (plus-becomes-×)

import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger, Icon } from "@sableui/react"

<Accordion defaultValue={["a"]}><AccordionItem value="a"><AccordionTrigger indicator={<Icon name="plus" className="text-xs text-muted-foreground motion-interactive [[data-panel-open]_&]:rotate-45" />}>Can I cancel anytime?</AccordionTrigger><AccordionPanel>Yes — from billing settings.</AccordionPanel></AccordionItem></Accordion>