Accordion

PreviousNext

A vertically stacked set of interactive headings that each reveal a section of content.

Installation

pnpm dlx bna-ui add accordion

Usage

import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from '@/components/ui/accordion';
<Accordion type='single' collapsible>
  <AccordionItem value='item-1'>
    <AccordionTrigger>Is it accessible?</AccordionTrigger>
    <AccordionContent>
      Yes. It adheres to the WAI-ARIA design pattern.
    </AccordionContent>
  </AccordionItem>
</Accordion>

Examples

Default

Single Selection

Multiple Selection

Controlled

FAQ Style

Non-Collapsible

Custom Styled

API Reference

Accordion

Contains all the parts of a collapsible accordion.

PropTypeDefaultDescription
hapticbooleantrueWhether to trigger haptic feedback when an item expands or collapses.
type'single' | 'multiple'-Determines whether one or multiple items can be opened at the same time.
valuestring | string[]-The controlled value of the item to expand when type is "single" or the controlled values of the items to expand when type is "multiple".
defaultValuestring | string[]-The value of the item to expand when initially rendered when type is "single" or the values of the items to expand when initially rendered when type is "multiple".
onValueChange(value: string | string[]) => void-Event handler called when the expanded state of an item changes.
collapsiblebooleanfalseWhen type is "single", allows closing content when clicking trigger for an open item.
childrenReact.ReactNode-One or more AccordionItem elements.

AccordionItem

Contains all the parts of a collapsible item.

PropTypeDescription
valuestringA unique value for the item.
childrenReact.ReactNodeAn AccordionTrigger and AccordionContent pair.

AccordionTrigger

Toggles the collapsed state of its associated item.

PropTypeDescription
childrenReact.ReactNodeThe content to display in the trigger.

AccordionContent

Contains the collapsible content for an item.

PropTypeDescription
childrenReact.ReactNodeThe content to display when the item is expanded.
styleobjectAdditional styles to apply to the content container.

Accessibility

Adheres to the Accordion WAI-ARIA design pattern.