Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Accordion

Free

Panels that animate to their measured height with a rotating indicator.

Installation

pnpm dlx shadcn@latest add @viewport/accordion

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above.

accordion-demo.tsx
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/viewport/accordion";

const faqs = [
  { q: "Can I use this in client projects?", a: "Yes. Free components are MIT licensed, and a Pro license covers unlimited personal and commercial projects." },
  { q: "Does it work with my design tokens?", a: "Components read the standard shadcn CSS variables, so they pick up your colors, radius and fonts automatically." },
  { q: "What about reduced motion?", a: "Every component checks the user's motion preference and falls back to an instant or static state." },
];

export default function AccordionDemo() {
  return (
    <Accordion type="single" collapsible defaultValue="item-0" className="w-full max-w-lg">
      {faqs.map(({ q, a }, i) => (
        <AccordionItem key={q} value={`item-${i}`}>
          <AccordionTrigger>{q}</AccordionTrigger>
          <AccordionContent>{a}</AccordionContent>
        </AccordionItem>
      ))}
    </Accordion>
  );
}

Accessibility

  • Built on Radix Accordion: arrow keys, Home and End.
  • Triggers sit inside headings and announce expanded state.
  • Respects prefers-reduced-motion.