All specs
Interactive · accordion

Accordion

Interactive collapsible sections for grouped content.

Anatomy

▸ General
  │ Name: my-app
  │ Version: 1.0.0

· Advanced
· About

↑↓ navigate · space/↵ toggle · q/esc quit

Usage

await accordion({
  sections: [
    { title: 'General',  content: 'Name: my-app\nVersion: 1.0.0' },
    { title: 'Advanced', content: 'Debug: false\nVerbose: true' },
    { title: 'About',    content: 'Caret design system v0.1' },
  ],
})

Options

KeyTypeDefaultDescription
sections{ title, content }[]Section list
defaultExpandednumber[]?[0]Initially expanded indices
multipleboolean?trueAllow multiple open sections

Keyboard

KeyAction
/ kPrevious section
/ jNext section
spaceToggle section
Toggle section
qQuit
escQuit

Do & don't

Do — use for long content split into logical groups (config, help sections)

Don't — use for single collapsible block (just use conditional rendering)

Out of scope

Animated expand/collapse transitions

Nested accordions

Drag-to-reorder sections