Skip to content
Primitives

Accordion

Index-numbered disclosure rows.

● LIVE

npx shadcn@latest add https://okibi.cndr.dev/r/accordion.json

Installation

Install the theme first, then add the component:

npx shadcn@latest add https://okibi.cndr.dev/r/accordion.json

Install the required dependencies:

npm install @radix-ui/react-accordion lucide-react

Copy the source from the Code tab above into components/ui/accordion.tsx. It uses the cn helper and the okibi theme tokens — install the theme first if you haven't.

Usage

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

<Accordion type="single" collapsible>
  <AccordionItem value="item-1">
    <AccordionTrigger>Section one</AccordionTrigger>
    <AccordionContent>Disclosure body…</AccordionContent>
  </AccordionItem>
</Accordion>

Anatomy

<Accordion type="single" collapsible>
  <AccordionItem value="item-1">    {/* unique value per row */}
    <AccordionTrigger index="01" /> {/* mono index is a Trigger prop, not Item */}
    <AccordionContent />
  </AccordionItem>
</Accordion>

API Reference

Accordion

PropTypeDefaultDescription
type"single" | "multiple"One open row at a time, or many.
collapsiblebooleanfalseAllow closing the open row (single only).

AccordionItem

PropTypeDefaultDescription
valuestringUnique id for the row.

AccordionTrigger

PropTypeDefaultDescription
indexstringOptional mono index annotation rendered before the trigger label.

Accessibility

  • Wraps Radix Accordion, which renders each trigger inside an AccordionPrimitive.Header and wires the button/region disclosure semantics and data-state.
  • Full keyboard model from the primitive: Enter/Space toggle a row, arrow keys move between triggers, Home/End jump to the first/last.
  • Triggers carry the standard square signal focus ring (ring-2 ring-ring with offset); disabled items are skipped and dimmed to opacity-60.
  • The chevron reticle is decorative (aria-hidden) and rotates via data-state=open, so its motion conveys nothing assistive tech needs.
  • type='single' allows one open row (add collapsible to close it); type='multiple' lets several stay open — the toggle state is announced by Radix.

Guidelines

Do

  • Put the mono index on AccordionTrigger, where it renders ahead of the label.
  • Add collapsible to a type='single' accordion when the open row should be closable back to all-collapsed.
  • Give each AccordionItem a unique value so open state tracks correctly.

Don't

  • Do not pass index to AccordionItem — it is an AccordionTrigger prop and is ignored on the item.
  • Do not bury primary actions inside a collapsed row; the content is hidden until the user opens it.
  • Do not re-add JS motion — the height keyframes are CSS-only and already reduced-motion gated.

On this page