Display

Accordion

Stacked questions that open to their answers. One open at a time unless multiple is set.

packages/design-system/components/ui/accordion.tsx

Examples

Two weeks from kickoff to handover, with a check-in every few days.

One at a time

Two weeks from kickoff to handover, with a check-in every few days.

Multiple

Anatomy

  1. 01Accordion, bordered and rounded
  2. 02Items, open ones tinted
  3. 03Trigger with chevrons
  4. 04Panel

Usage

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

<Accordion defaultValue={["time"]}>
  <AccordionItem value="time">
    <AccordionTrigger>How long does a sprint take?</AccordionTrigger>
    <AccordionContent>Two weeks.</AccordionContent>
  </AccordionItem>
</Accordion>

Props

PropTypeDefaultDescription
value / defaultValueany[]noneThe open items' values. Always an array.
multiplebooleanfalseLet more than one item be open.
onValueChange(value, details) => voidnoneCalled with the open values.
AccordionItem valueanynoneIdentifies the item.
classNamestringnoneMerged last with cn(). Use it for layout (width, margin), not to restyle the component.

Guidance

Do

  • Write triggers as the question people would ask.

Don't

  • Hide something everyone needs inside it.

Where it's used