Accordion

A set of collapsible panels with headings.

API Reference

Installation

npx love-ui@latest add accordion

Usage

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

Examples

Single Accordion

Multiple Accordion

Controlled Accordion

Comparing with Radix / shadcn

If you’re already familiar with Radix UI and shadcn/ui, this guide highlights the small differences and similarities so you can get started with loveui quickly.

Prop Mapping

ComponentRadix UI PropBase UI Prop
Accordiontype (enum, "single" or "multiple")multiple (boolean, default: true)
Accordioncollapsibleremoved

Quick Checklist

  • Replace type="single"multiple={false} on Accordion
  • Remove type="multiple" from Accordion
  • Remove collapsible from Accordion
  • Always use arrays for defaultValue
  • Use AccordionPanel going forward; AccordionContent remains for legacy
  • If you used asChild on parts, switch to the render prop

Comparison Example

shadcn/ui
<Accordion type="multiple" collapsible defaultValue="item-1">
  <AccordionItem value="item-1">
    <AccordionTrigger>Title</AccordionTrigger>
    <AccordionContent>Content</AccordionContent>
  </AccordionItem>
</Accordion>
loveui
<Accordion multiple={false} defaultValue={["item-1"]}>
  <AccordionItem value="item-1">
    <AccordionTrigger>Title</AccordionTrigger>
    <AccordionPanel>Content</AccordionPanel>
  </AccordionItem>
</Accordion>