Skip to content

Accordion

Expandable content sections that allow users to show and hide related content. Supports single and multiple expansion, two visual variants, and controlled/uncontrolled state.

Also known as: collapsible, expandable, disclosure, collapse panel

View in Storybook

When to use

  • Organizing content into collapsible sections (FAQ, settings, menus).
  • Reducing visual clutter by hiding secondary content.
  • Displaying lists of items where only one or a few need to be visible at a time.

Import

tsx
import { Accordion } from '@vacano/ui'

Usage

tsx
const items = [
  { value: 'section-1', title: 'Section 1', content: 'Content for section 1' },
  { value: 'section-2', title: 'Section 2', content: 'Content for section 2' },
]

<Accordion items={items} />

Variants

Outlined

Items separated by border lines.

tsx
<Accordion items={items} variant="outlined" />

Splitted

Items as separate rounded cards with gap between them.

tsx
<Accordion items={items} variant="splitted" />

Multiple

Allow multiple items to be expanded at the same time.

tsx
<Accordion items={items} multiple />

Default expanded

Pre-expand specific items on mount.

tsx
<Accordion items={items} defaultValue={['section-1']} />

Controlled

Control the expanded state externally.

tsx
const [value, setValue] = useState(['section-1'])

<Accordion items={items} value={value} onChange={setValue} />

Disabled items

Individual items can be disabled.

tsx
const items = [
  { value: '1', title: 'Available', content: '...' },
  { value: '2', title: 'Disabled', content: '...', disabled: true },
]

<Accordion items={items} />

Props

PropTypeDefaultDescription
itemsAccordionItem[]requiredArray of accordion items
variant'outlined' | 'splitted''outlined'Visual style variant
multiplebooleanfalseAllow multiple items open simultaneously
valuestring[]-Controlled expanded item values
defaultValuestring[][]Initially expanded items (uncontrolled)
onChange(value: string[]) => void-Callback when expanded items change
classNamestring-CSS class name for the root element
classnamesAccordionClassNames-Custom class names for sub-elements
refRef<HTMLDivElement>-Ref forwarded to the root element
data-test-idstring-Test identifier attribute

AccordionItem

PropertyTypeDefaultDescription
valuestringrequiredUnique identifier for the item
titleReactNoderequiredTrigger label
contentReactNoderequiredExpandable content
disabledbooleanfalseDisable interaction

AccordionClassNames

KeyDescription
itemAccordion item wrapper
triggerClickable header button
contentExpanded content area
iconChevron icon
  • Tabs - Switch between content views
  • Stepper - Step-by-step navigation
  • Panel - Container for grouped content

Released under the MIT License.