Skip to content

Accordion

A stack of collapsible sections. Open one at a time, or several. Full keyboard path.

On this page
Used for
  • Settings groups
  • FAQ lists
  • Run step details
  • Model option groups

Examples

Installation

npx knowns-ui@latest add accordion
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

type
"single" | "multiple"
Default"single"
One open, or several.
collapsible
boolean
Defaulttrue
For type=single, whether the open item can be closed.
defaultValue / value
string | string[]
Which items start (or stay) open. A string for single, an array for multiple.
onValueChange
(value) => void
Fires with a string (single) or string[] (multiple).

What it handles

  1. 01Stacks AccordionItem sections, each with an AccordionTrigger and an AccordionContent that carries the region role.
  2. 02Opens one item at a time with `type="single"`, and `collapsible` decides whether the open item can be closed again.
  3. 03Opens several at once with `type="multiple"`, and `defaultValue`, `value` and `onValueChange` set or follow the open items.
  4. 04Toggles with Enter or Space, moves between headers with the up and down arrows, and wraps around at both ends.
  5. 05Jumps to the first or last header with Home and End.
  6. 06Marks closed content inert, so its links and fields cannot be focused while it is hidden.

States

First render
Nothing. Each item paints open or closed
none
Open
The content grows from 0 to its height and fades in
180ms, ease out
Close
The content shrinks to 0 and fades out
180ms, ease out
Chevron
The chevron turns half a turn
180ms, ease out
Reduced motion
The content opens and closes at once
0ms

Works with

When to use

When to use

  • Stacks of sections the user opens one or several at a time, such as FAQs or settings groups.

When not to use

  • Switching between equal panels: use Tabs.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Accordion to my app and wire it to my own data.
  • I need stacks of sections the user opens one or several at a time, such as FAQs or settings groups. Set that up with the Knowns UI Accordion.
  • Which Accordion props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "accordion" }) and search_docs({ query: "accordion" }).

Need help?

Stuck on Accordion, or found something off? We read every message.