Skip to content

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

Tab-Style Accordion for Solid

Account questions as separate rounded cards, with the chevron on the right and the email question open.

UI library: Ark UI

Four account questions, each in its own rounded card with a gap between them. The chevron sits on the right, and How do I change my email address? starts open.

Use it when each answer should feel separate. If people switch among them often, use Tabs. In Solid, Ark UI opens one card at a time in this demo.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

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

Usage

<Accordion class="flex w-full max-w-md flex-col gap-2" defaultValue={["email"]}>
    {items.map(item => <AccordionItem class="overflow-hidden rounded-lg border bg-background px-4" value={item.value}>
        <AccordionTrigger>{item.title}</AccordionTrigger>
        <AccordionContent>
          <p class="text-muted-foreground">{item.content}</p>
        </AccordionContent>
      </AccordionItem>)}
  </Accordion>

FAQ

How are the sections separated?

Accordion is flex flex-col gap-2, so each row has its own border. Each AccordionItem has rounded-lg border and px-4.

Which chevron is this?

AccordionTrigger is used with the title only, so it draws the built-in chevron on the right. This demo does not hide accordion-trigger-icon.

Why does the email question start open?

defaultValue={["email"]} opens the email question 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.

How wide is the stack?

Accordion sets w-full max-w-md. The items stretch to that width, and overflow-hidden on each item keeps the open answer inside the rounded border.

Is keyboard navigation built in?

Yes. Each trigger is a button with aria-expanded and aria-controls, and Enter or Space toggles it. The arrow keys move between triggers, and Home and End jump to the first and last.

API Reference

Accordion

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