Staaarter

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.

By Staaarter Team
FAQ
Docs
Live preview

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.json

Prefer 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

PropTypeDefaultDescription
headingstring"Frequently asked questions"Section heading.
descriptionstringundefinedOptional supporting copy under the heading.
itemsFaq7Item[]noneOrdered list of question and answer cards.
defaultOpenIndexnumber0Index of the card expanded on initial render; pass -1 to start fully collapsed.
classNamestringnoneExtra 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.