Search

Search documentation

Accordion

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

Installation

pnpm dlx shadcn@latest add @evolphin/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>

Type Definitions

interface AccordionProps {
  /** The type of accordion: "single" or "multiple" */
  type: "single" | "multiple";
AccordionProps.type: "single" | "multiple"

The type of accordion: "single" or "multiple"

/** Whether an accordion item can be collapsed after it has been opened */ ?: boolean; /** The value of the item to expand */ ?: string | string[]; /** Whether the component is disabled */ ?: boolean; }

Examples

Default

API Reference

Accordion

PropTypeDefaultDescription
type"single" | "multiple"-Determines whether one or multiple items can be opened at the same time.
collapsiblebooleanfalseWhen type is "single", allows closing content when clicking trigger for an open item.
valuestring-The controlled value of the item to expand.
defaultValuestring-The default value of the item to expand.
onValueChange(value: string) => void-Event handler called when the expanded state of an item changes.
disabledbooleanfalseWhen true, prevents the user from interacting with the accordion.
dir"ltr" | "rtl""ltr"The reading direction of the accordion.
orientation"vertical" | "horizontal""vertical"The orientation of the accordion.

AccordionItem

PropTypeDefaultDescription
valuestring-A unique value for the item.
disabledbooleanfalseWhen true, prevents the user from interacting with the item.
classNamestring-Additional CSS classes

AccordionTrigger

PropTypeDefaultDescription
childrenReact.ReactNode-The content of the trigger.
classNamestring-Additional CSS classes

AccordionContent

PropTypeDefaultDescription
childrenReact.ReactNode-The content of the accordion.
classNamestring-Additional CSS classes

Accessibility

  • Keyboard:
    • Space or Enter: When focus is on an AccordionTrigger, expands or collapses the associated content.
    • Tab: Moves focus to the next focusable element.
    • ArrowDown / ArrowUp: Moves focus to the next/previous trigger.
    • Home / End: Moves focus to the first/last trigger.
  • Screen Reader:
    • The AccordionTrigger has aria-controls set to the ID of the AccordionContent.
    • The AccordionTrigger has aria-expanded set to true or false.
    • The AccordionContent has role="region" and aria-labelledby set to the ID of the AccordionTrigger.

On this page