Skip to content

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

Free

Accordion with Category Icons for Ark UI

A bordered accordion of Documents, Projects, Workspace settings, and Team members, each led by an icon.

Four workspace sections in one bordered stack. Each trigger starts with an icon, Documents starts open, and the chevron sits on the right.

Use it when the sections are different kinds of content. If there is only one section, a Collapsible is enough. In React, Ark UI does not remember which section was open.

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="text-start">{item.title}</span>
        </span>
      </AccordionTrigger>
      <AccordionContent className="ps-7">
        <p className="text-muted-foreground">{item.content}</p>
      </AccordionContent>
    </AccordionItem>
  ))}
</Accordion>

FAQ

What types of icons work best for accordion sections?

Icons that name the content: FileTextIcon for documents, FolderIcon for collections, SettingsIcon for configuration, UsersIcon for people. Avoid arrows and chevrons, which read as the expand indicator.

How do I change icon colors to match section categories?

The icons use text-muted-foreground so they don't compete with the titles. To color-code categories, add a color to each item in the data and apply it to its icon, using theme tokens such as text-primary or text-destructive so the colors follow light and dark mode.

Can I use different icon sizes for emphasis?

You can, but keep one size per accordion. Every icon here is size-4, which matches the trigger's text. A bigger icon on one row makes that row taller and pushes its title out of line with the others.

Why is content indented with ps-7?

ps-7 is 28px: the 16px icon plus the 12px gap-3 between icon and title. It lines each answer up under its title rather than under the icon, so the content reads as belonging to that heading.

Can I use custom SVG icons instead of Lucide?

Yes. Each item stores its icon component in the data, so any icon component works in its place. Keep size-4, shrink-0 and aria-hidden on it so it sizes, aligns and stays silent like the Lucide ones.

How do I show a loading state for a section?

Swap that item's icon for LoaderIcon with animate-spin while its content loads, and put the loading message in AccordionContent too, since the icon is hidden from screen readers.

API Reference

Accordion

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