Shadcn Accordion
React accordion component for collapsible content sections. Built with TypeScript and Tailwind CSS for Next.js with keyboard navigation support.
Accordion animations jerky?
Join our Discord community for help from other developers.
Ever built a FAQ page where users had to scroll through walls of text to find one answer? Yeah, that's painful for everyone involved. This shadcn/ui accordion component solves that problem by letting users focus on what they actually need in your Next.js app—no scrolling through irrelevant content, no overwhelming walls of text.
FAQ accordion
Standard accordion for frequently asked questions:
The animations feel smooth, keyboard navigation works like you'd expect, and screen readers handle everything properly. Built with TypeScript for type safety and styled with Tailwind CSS classes.
npx shadcn@latest add accordion
Why accordions actually work
Here's the thing—accordions aren't just about saving space. They're about respecting your users' attention. Instead of forcing someone to process everything at once, you let them choose what's relevant.
Think of it like a good table of contents—users scan headers, find what they need, and ignore the rest. That's smart information architecture that shadcn/ui components make effortless.
You can fit tons of content without making pages feel overwhelming. This becomes super important on mobile where every pixel matters.
Built on Radix UI primitives, this shadcn/ui component follows the WAI-ARIA accordion design pattern. Full keyboard navigation, screen reader support, and proper focus management work automatically. No extra JavaScript configuration needed.
Real patterns you'll actually use
Settings panel with multiple sections
Organize privacy controls, notifications, and account settings. Shows multiple expansion mode in action with Switch components:
Controlled state
Programmatically control which sections are open—useful for guided tours or linking to specific sections:
Multi-level nested accordion
Create hierarchical content with nested Collapsible sections and icons at all levels:
Each pattern serves different use cases in your React applications. Whether you're building with Next.js or another framework, these accordion patterns handle the complex state management so you don't have to.
Features
The accordion component includes everything you need:
- Full keyboard navigation - Arrow keys, Space, Enter, Home, End all work as expected
- Flexible expansion modes - Single or multiple items can be open simultaneously
- Controlled or uncontrolled - Use with React state or let the component manage itself
- Animation ready - CSS variables for content height/width make smooth animations easy
- Accessibility first - WAI-ARIA compliant with proper focus management and screen reader support
- TypeScript native - Built with TypeScript, works perfectly in JavaScript projects too
API Reference
Prop | Type | Default |
---|---|---|
type? | "single" | "multiple" | "single" |
collapsible? | boolean | false |
defaultValue? | string | string[] | - |
value? | string | string[] | - |
onValueChange? | (value: string | string[]) => void | - |
Keyboard interactions
Built on Radix UI, the accordion supports full keyboard navigation:
Key | Description |
---|---|
Space / Enter | Toggles the focused accordion item |
Tab | Moves focus to next focusable element |
Shift + Tab | Moves focus to previous focusable element |
ArrowDown | Moves focus to next accordion trigger |
ArrowUp | Moves focus to previous accordion trigger |
Home | Moves focus to first accordion trigger |
End | Moves focus to last accordion trigger |
Production tips
Performance matters. This free shadcn/ui component is lightweight and works great in TypeScript projects. The Tailwind CSS styling keeps bundle sizes small while maintaining full customization.
Default states create better UX. For FAQs, keep everything closed—let users choose what to open. For dashboards, consider opening the most important section by default. Similar to Tabs, think about which content users need first.
Trigger labels should be scannable. "Payment & Billing" beats "Manage your payment methods and billing preferences." Users need to scan quickly.
Test keyboard navigation thoroughly. Arrow keys should move between triggers, Space/Enter should toggle items. This open source shadcn/ui component handles focus management, but custom triggers need testing.
Radix UI foundation. This component wraps @radix-ui/react-accordion
, giving you unstyled primitives with perfect accessibility. The shadcn/ui styling layer adds beautiful defaults while keeping full customization possible.
Integration with other components
Accordions work great with Form components for organizing complex React interfaces. Combine with Badge components to show status or counts in trigger headers. Use Lucide React icons for visual hierarchy—the shadcn/ui design system makes these integrations smooth in JavaScript applications.
Questions you might have
Install shadcn/ui Vite
Install shadcn/ui with Vite React projects for fast development. Complete setup guide with Tailwind CSS v4 and TypeScript configuration.
Shadcn Alert Dialog
React alert dialog for confirmation modals and destructive actions. Built with TypeScript and Tailwind CSS for Next.js applications with focus management.