Skip to main content
The Accordion component allows users to show and hide sections of related content. It supports both single and multiple item expansion modes, with smooth animations and full keyboard navigation.

Installation

npx shadcn@latest add @eo-n/accordion

Usage

Import the Accordion components and compose them together:
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from "@/components/ui/accordion";
<Accordion>
  <AccordionItem value="item-1">
    <AccordionTrigger>Is it accessible?</AccordionTrigger>
    <AccordionContent>
      Yes. It adheres to the WAI-ARIA design pattern and is fully keyboard
      navigable. The component is built with proper focus management and ARIA
      attributes for screen reader compatibility.
    </AccordionContent>
  </AccordionItem>
</Accordion>

Component API

Accordion

The root container component that manages accordion state.
multiple
boolean
default:"false"
Whether multiple accordion items can be open at the same time. When false, opening one item automatically closes others.
defaultValue
string | string[]
The value(s) of the item(s) that should be open by default.
value
string | string[]
The controlled value of the open item(s).
onValueChange
(value: string | string[]) => void
Callback fired when the open items change.
className
string
Additional CSS classes to apply.

AccordionItem

Container for an individual accordion item.
value
string
required
Unique identifier for this accordion item.
disabled
boolean
Whether the accordion item is disabled.
className
string
Additional CSS classes to apply to the item.

AccordionTrigger

The clickable header that toggles the accordion item.
className
string
Additional CSS classes to apply to the trigger.

AccordionContent

The collapsible content panel.
className
string
Additional CSS classes to apply to the content wrapper.

Examples

Single Item Open (Default)

By default, only one accordion item can be open at a time:
<Accordion defaultValue="item-1">
  <AccordionItem value="item-1">
    <AccordionTrigger>What is EoN UI?</AccordionTrigger>
    <AccordionContent>
      EoN UI is a modern React component library built with accessibility and
      customization in mind.
    </AccordionContent>
  </AccordionItem>
  <AccordionItem value="item-2">
    <AccordionTrigger>How do I install it?</AccordionTrigger>
    <AccordionContent>
      You can install components using the CLI or copy them manually into your project.
    </AccordionContent>
  </AccordionItem>
  <AccordionItem value="item-3">
    <AccordionTrigger>Is it free?</AccordionTrigger>
    <AccordionContent>
      Yes, EoN UI is completely free and open source.
    </AccordionContent>
  </AccordionItem>
</Accordion>

Multiple Items Open

Allow multiple items to be expanded simultaneously:
<Accordion multiple defaultValue={["item-1", "item-2"]}>
  <AccordionItem value="item-1">
    <AccordionTrigger>Features</AccordionTrigger>
    <AccordionContent>
      Built with TypeScript, fully accessible, and customizable.
    </AccordionContent>
  </AccordionItem>
  <AccordionItem value="item-2">
    <AccordionTrigger>Documentation</AccordionTrigger>
    <AccordionContent>
      Comprehensive docs with examples and API references.
    </AccordionContent>
  </AccordionItem>
  <AccordionItem value="item-3">
    <AccordionTrigger>Support</AccordionTrigger>
    <AccordionContent>
      Community support through GitHub discussions.
    </AccordionContent>
  </AccordionItem>
</Accordion>

Disabled Item

Disable specific accordion items:
<Accordion>
  <AccordionItem value="item-1">
    <AccordionTrigger>Available Item</AccordionTrigger>
    <AccordionContent>This item is available and can be opened.</AccordionContent>
  </AccordionItem>
  <AccordionItem value="item-2" disabled>
    <AccordionTrigger>Disabled Item</AccordionTrigger>
    <AccordionContent>This content cannot be accessed.</AccordionContent>
  </AccordionItem>
</Accordion>

Controlled Accordion

Fully control the accordion state:
function ControlledAccordion() {
  const [openItems, setOpenItems] = React.useState(["item-1"]);

  return (
    <Accordion multiple value={openItems} onValueChange={setOpenItems}>
      <AccordionItem value="item-1">
        <AccordionTrigger>First Item</AccordionTrigger>
        <AccordionContent>First content</AccordionContent>
      </AccordionItem>
      <AccordionItem value="item-2">
        <AccordionTrigger>Second Item</AccordionTrigger>
        <AccordionContent>Second content</AccordionContent>
      </AccordionItem>
    </Accordion>
  );
}

Accessibility

The Accordion component is built on Base UI’s accessible Accordion primitive, which:
  • Implements the ARIA accordion design pattern
  • Supports full keyboard navigation (Tab, Space, Enter, Arrow keys)
  • Properly manages focus between triggers and content
  • Uses appropriate ARIA attributes for screen readers
  • Supports disabled states
  • Includes smooth animations for expand/collapse transitions
For more details, see the Base UI Accordion documentation.

Build docs developers (and LLMs) love