Dokumentation (english)
Components: Shadcn UI

Accordion

Understand the design system and contribute to it

Component preview

The live preview for UI components is handled by components/atoms/codedocs/ComponentPreview.tsx. Use it directly inside MDX whenever you want a playground-style embed. Provide componentProps to set default values and propOptions to surface toggle-able props next to the preview.

Preview

Prop reference

Auto-generated from the component source

Accordion

All props are forwarded to the underlying primitive.

React.ComponentProps<typeof AccordionPrimitive.Root>

AccordionContent

  • className
  • children

React.ComponentProps<typeof AccordionPrimitive.Content>

AccordionItem

  • className

React.ComponentProps<typeof AccordionPrimitive.Item>

AccordionTrigger

  • className
  • children

React.ComponentProps<typeof AccordionPrimitive.Trigger>

Code
// owner: Sona
"use client";

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

const faqItems = [
  {
    id: "item-1",
    question: "What is AICU?",
    answer:
      "A collaborative UI system that ships with accessible primitives, sensible defaults, and opinionated styling.",
  },
  {
    id: "item-2",
    question: "Can I customize the components?",
    answer:
      "Yes. Use Tailwind utility classes or override props to make each component your own.",
  },
  {
    id: "item-3",
    question: "Do the accordions support multiple items?",
    answer:
      "Switch the type to 'multiple' to keep several sections open at the same time.",
  },
];

export default function AccordionExample() {
  return (
    <Accordion type="single" collapsible className="w-full max-w-2xl">
      {faqItems.map((item) => (
        <AccordionItem key={item.id} value={item.id}>
          <AccordionTrigger>{item.question}</AccordionTrigger>
          <AccordionContent>{item.answer}</AccordionContent>
        </AccordionItem>
      ))}
    </Accordion>
  );
}

On this page


Command Palette

Search for a command to run...

Schnellzugriffe
STRG + KSuche
STRG + DNachtmodus / Tagmodus
STRG + LSprache ändern

Software-Details
Kompiliert vor 15 Tagen
Release: v4.0.0-production
Buildnummer: master@6fbd7b5
Historie: 13 Items