Collapsible Accordion
An accordion styled as a stack of bordered, shadowed cards rather than plain hairline rows. Use when you need to present multiple questions with full-length answers in a compact, organized format that still feels distinct item to item.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/collapsible-accordion.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/faq/faq7.tsx instead.
Usage
The file also exports faq7Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Faq7, faq7Demo } from "@/components/blocks/faq/faq7"; export default function Page() { return <Faq7 {...faq7Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "Frequently asked questions" | Section heading. |
| description | string | undefined | Optional supporting copy under the heading. |
| items | Faq7Item[] | none | Ordered list of question and answer cards. |
| defaultOpenIndex | number | 0 | Index of the card expanded on initial render; pass -1 to start fully collapsed. |
| className | string | none | Extra classes for the outer section element. |
Types
type Faq7Item = { question: string; answer: string };
Behavior notes
- Real interactivity: each card's question is a real button with aria-expanded/aria-controls, and only one card is open at a time, opening a new one closes the previously open one.
- Cards are visually distinct bordered, shadowed containers with space-y-3 gaps between them, rather than a single divided list.
- The first item is open by default via defaultOpenIndex, which can be set to any index or an out-of-range value to start fully collapsed.
More FAQ Blocks
View all →open-list-layout
Open List Layout
Questions with answers displayed directly below in a simple always-open list.
three-column-grid
Three Column Grid
Q&A pairs arranged in a responsive grid layout, always open.
tabbed-categories
Tabbed Categories
Sidebar navigation with category tabs and an accordion of that category's questions.
searchable-accordion
Searchable Accordion
Search input that filters accordion items in real-time by question and answer text.
grouped-sections
Grouped Sections
FAQs organized into titled sections, each with its own independent accordion below it.
side-by-side-image
Side-by-Side Image
Accordion paired with a large image on the left or right.