Navigation
Accordion
Disclosure sections for FAQs and grouped settings, with full keyboard support.
Installation
Copy the source with the CLI to own and edit it, or import it from the npm package.
npx aback-ui@latest add accordionWrites components/ui/accordion.tsx. First time in this project? Run npx aback-ui@latest init first, as the installation guide shows.
Usage
Import the parts you need from the installed file. The Code tab above has a complete, working example.
import {
Accordion,
AccordionItem,
AccordionTrigger,
AccordionContent,
} from "@/components/ui/accordion";API reference
Props and composition points for Accordion. Native element props pass through.
| Prop | Type | Default | Description |
|---|---|---|---|
type | "single" | "multiple" | None | Whether one or several panels can be open at once. Required. |
collapsible | boolean | false | In single mode, allows the open panel to close when activated again. |
defaultValue | string | string[] | None | Panels open on first render in uncontrolled mode. |
value / onValueChange | string | string[] / (value) => void | None | Controlled open state. Use either the uncontrolled or controlled API. |
forceMount | boolean | None | On AccordionContent, keeps closed answers in the DOM for SEO. Pair with hidden styling. |
Dependencies: radix-ui, @tabler/icons-react, plus the shared @/lib/utils helper.
Accessibility
Semantics, keyboard behavior, and the decisions that keep the component operable.
- Each trigger is a real button inside a heading, with aria-expanded and aria-controls managed by Radix.
- The trigger order forms a single tab stop; arrow keys, Home, and End move between headers.
- Closed content is unmounted by default. Pass forceMount when the answer must exist in the initial HTML.
- The chevron is decorative and hidden from assistive technology; the label alone names the control.
Keyboard
| Key | Action |
|---|---|
| EnterorSpace | Toggle the focused panel. |
| ArrowDownorArrowUp | Move focus to the next or previous header. |
| HomeorEnd | Move focus to the first or last header. |
Avoid fixed max heights on answers. The content animates from its measured height so long localized text is never clipped.
Used in production
The Aback products whose interfaces shaped this component.