Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Accordion with Icon, Subtitle, and Chevron for React

Workspace rows with an icon, a title, a muted subtitle, and the chevron on the right. Documents starts open.

Each trigger has an icon, a title, and a muted subtitle, with the chevron on the right. Documents starts open, and its subtitle names contracts, invoices, and briefs.

Use it when the title alone is not enough to pick a section. A single block of details can be a Collapsible. In React, Base UI does not write the subtitles.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Use email insteadNo credit card

Anatomy

Accordion anatomy: root, item, item trigger, item content, item indicator

Usage

<Accordion
  className="w-full max-w-md -space-y-px"
  defaultValue={["documents"]}
>
  {items.map((item) => (
    <AccordionItem
      className="overflow-hidden border bg-background px-4 first:rounded-t-lg last:rounded-b-lg"
      key={item.value}
      value={item.value}
    >
      <AccordionTrigger className="hover:no-underline">
        <span className="flex items-center gap-3">
          <item.icon
            aria-hidden="true"
            className="size-4 shrink-0 text-muted-foreground"
          />
          <span className="flex flex-col items-start text-start">
            <span>{item.title}</span>
            <span className="text-muted-foreground text-sm">
              {item.subtitle}
            </span>
          </span>
        </span>
      </AccordionTrigger>
      <AccordionContent className="ps-7">
        <p className="text-muted-foreground">{item.content}</p>
      </AccordionContent>
    </AccordionItem>
  ))}
</Accordion>

FAQ

Where do the category icons come from?

Each item stores FileTextIcon, FolderIcon, SettingsIcon or UsersIcon. The trigger renders it at size-4 with text-muted-foreground, shrink-0 and aria-hidden, in a gap-3 row before the text.

Where is the chevron?

AccordionTrigger draws its own chevron on the right. This trigger does not hide accordion-trigger-icon, and hover:no-underline is set on the trigger.

How is the subtitle marked up?

Title and subtitle stack in flex flex-col items-start text-start. The subtitle is text-sm text-muted-foreground.

Why is the answer indented?

ps-7 on AccordionContent matches the 16px icon plus the 12px gap-3, so the answer lines up under the title.

Why does Documents start open?

defaultValue={["documents"]} opens Documents on first render. The string matches that item's value.

How do I let several items stay open at once?

One open item is the default. Add multiple to Accordion to let several stay open, and list every item that should start open in the defaultValue array.

API Reference

Accordion

Sets defaultValue={["documents"]} and value={item.value}. The rest is on the Accordion page.