MiComponents/Documentation

Accordion

A vertically stacked set of interactive headings that each reveal associated sections of content.

Installation

npx micomponents-cli add accordion

Preview

Usage

Import

import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from "@/components/ui/accordion"

Basic Usage

<Accordion type="single" collapsible className="w-full">
  <AccordionItem value="item-1">
    <AccordionTrigger>Is it accessible?</AccordionTrigger>
    <AccordionContent>
      Yes. It adheres to the WAI-ARIA design pattern.
    </AccordionContent>
  </AccordionItem>
  <AccordionItem value="item-2">
    <AccordionTrigger>Is it styled?</AccordionTrigger>
    <AccordionContent>
      Yes. It comes with default styles that you can customize.
    </AccordionContent>
  </AccordionItem>
  <AccordionItem value="item-3">
    <AccordionTrigger>Is it animated?</AccordionTrigger>
    <AccordionContent>
      Yes. It's animated by default but you can disable it.
    </AccordionContent>
  </AccordionItem>
</Accordion>

Examples

Single Collapsible

Use type="single" to allow only one item to be open at a time. Opening a new item automatically closes the previous one.

Multiple Open Items

Use type="multiple" to allow multiple items to be open at the same time.

API Reference

PropTypeDefaultDescription
type"single" | "multiple"-Determines if one or multiple items can be open
collapsiblebooleanfalseWhen false, one item will always be open
disabledbooleanfalseDisables the accordion