Skip to content
shadcn.io is not affiliated with official shadcn/ui

Shadcn Accordion for React and Tailwind

Open one panel or many. For FAQs, settings, and other disclosure UI.

Preview

Our flagship product combines cutting-edge technology with sleek design. Built with premium materials, it offers unparalleled performance and reliability.

Key features include advanced processing capabilities, and an intuitive user interface designed for both beginners and experts.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/accordion.json

Anatomy

Accordion anatomy: root, item, item trigger, item content, item indicator

Usage

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

Demos

Multiple

Use multiple to keep more than one item open.

Horizontal

Use orientation="horizontal" for a row of vertical triggers. Open items expand sideways using --width.

Disabled

Pass disabled on an item to take it out of the keyboard flow.

Card

Wrap the accordion in a Card for a settings or FAQ block.

Controlled

Drive the open items with value and onValueChange.

API Reference

shadcn.io wraps Ark UI Accordion. Defaults below are shadcn.io values — they differ from Ark for collapsible (true here, false in Ark) and for lazyMount / unmountOnExit (on for vertical, off for horizontal).

Every part accepts className and asChild. asChild merges props onto a single child element instead of rendering the default tag.

Accordion

Root. Renders a div.

PropType

AccordionItem

Single item. Renders a div.

PropType

AccordionTrigger

Button that expands or collapses its item. Renders a button and includes the chevron indicator (hidden when orientation="horizontal"). No props beyond className and asChild.

AccordionContent

Collapsible panel. Renders a div. No props beyond className and asChild.

CSS variableDescription
--heightMeasured content height. Used by the vertical open/close animation.
--widthMeasured content width. Used by the horizontal open/close animation.

AccordionRootProvider

Root alternative that takes the API from useAccordion. Renders a div. Pass collapsible, orientation, multiple, and the other machine options to useAccordion(), not to AccordionRootProvider.

PropType

useAccordion

Creates the accordion API for AccordionRootProvider. Accepts the same options as Accordion except asChild and className.

const accordion = useAccordion({
  collapsible: true,
  defaultValue: ["item-1"],
  multiple: true,
});

AccordionContext / useAccordionContext

Render-prop or hook access to accordion state. Use inside Accordion or AccordionRootProvider. AccordionContext children: (context) => ReactNode.

PropType

AccordionItemContext / useAccordionItemContext

Render-prop or hook access to one item. Use inside AccordionItem. AccordionItemContext children: (context) => ReactNode.

PropType

Data attributes

Every part sets data-scope="accordion" and data-orientation ("horizontal" or "vertical"). Item-level parts (item, trigger, content, indicator) also set data-state ("open" or "closed"), data-disabled when disabled, and data-focus when the trigger is focused.

Partdata-slotdata-part
Accordion / AccordionRootProvideraccordionroot
AccordionItemaccordion-itemitem
AccordionTriggeraccordion-triggeritem-trigger
AccordionContentaccordion-contentitem-content
Indicator (built into the trigger)accordion-indicatoritem-indicator

AccordionTrigger also sets data-controls with the id of its content panel.

Accessibility

Complies with the Accordion WAI-ARIA design pattern.

Keyboard support

KeyDescription
SpaceWhen focus is on a collapsed trigger, expand the item.
EnterWhen focus is on a collapsed trigger, expand the item.
TabMove focus to the next focusable element.
Shift + TabMove focus to the previous focusable element.
ArrowDownMove focus to the next trigger (vertical).
ArrowUpMove focus to the previous trigger (vertical).
ArrowRightMove focus to the next trigger (horizontal).
ArrowLeftMove focus to the previous trigger (horizontal).
HomeMove focus to the first trigger.
EndMove focus to the last trigger.