Accordion

Collapsible panels for FAQs or content organization.

Basic Accordion

With Icons

Multiple Expanded Items

This item is expanded by default.

This item is also expanded by default.

Usage

import { Accordion } from "@/components/accordion"
import { Info, HelpCircle } from 'lucide-react'

export default function MyComponent() {
  return (
    <Accordion
      allowMultiple={true}
      defaultExpandedIds={["item1"]}
      items={[
        {
          id: "item1",
          title: "First Item",
          icon: <Info className="h-4 w-4" />,
          content: <div>First item content</div>
        },
        {
          id: "item2",
          title: "Second Item",
          icon: <HelpCircle className="h-4 w-4" />,
          content: <div>Second item content</div>
        },
        {
          id: "item3",
          title: "Disabled Item",
          disabled: true,
          content: <div>This content won't be visible</div>
        },
      ]}
    />
  )
}

Props

Name
Type
Default
Description
items
array
required
Array of item objects with id, title, content, icon, and disabled properties.
defaultExpandedIds
string[]
[]
Array of item IDs that should be expanded by default.
allowMultiple
boolean
false
Whether multiple items can be expanded simultaneously.
className
string
undefined
Additional CSS classes to apply to the accordion container.