shadcn.io is not affiliated with official shadcn/ui
Accordion examples · Standard
Accordion with Category Icons for React
An accordion of workspace sections, each trigger led by an icon for its category, with the chevron on the right.
When sections hold different kinds of content (documents, projects, settings, people), a plain text label makes people read every row. This React accordion puts a Lucide icon before each title so the category registers at a glance. The icons come from the data, the answers line up under the titles, and the chevron that AccordionTrigger draws stays on the right. It suits dashboards, admin panels and documentation with distinct content types.
Preview
Installation
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.
Related
- Standard Accordion with ChevronA bordered accordion of three questions
- Accordion with Icons and Plus/Minus ToggleAn accordion of workspace sections with a
- Multi-Level Accordion with IconsAn accordion of workspace sections with a
- Accordion Form with Icon SectionsA form split into personal, contact and
- Accordion with Subtitle TextA bordered accordion of help topics where
- Card CollapsibleA card with a Features header that