Faq Section
An FAQ section with a heading column and an accessible accordion: one answer open at a time, arrow key navigation, aria-expanded and smooth row animation.
Installation
npx shadcn@latest add @minidev/faq-section
MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/faq-section.json
Usage
import { FaqSection } from "@/components/ui/faq-section"
export function Example() {
return (
<FaqSection />
)
}
API reference
| Prop | Type | Default |
|---|---|---|
| eyebrowSmall mono label above the title. Empty string hides it. | string | "FAQ" |
| titleSection heading (rendered as h2). | React.ReactNode | "Questions, answered." |
| descriptionLine under the heading, e.g. how to reach a person. | React.ReactNode | "Something else on your mind? Write t... |
| itemsQuestions in order. Defaults to Lumen's FAQ. | Faq[] | ITEMS |
| defaultOpenIndex of the question open on first render; `null` starts all closed. | number | null | 0 |
| className | string | - |
When to use
Use near the end of a marketing page, before the closing CTA. Answers open by animating grid rows (no measuring) and the plus turns into a cross. Keyboard follows the WAI-ARIA accordion pattern: Enter/Space toggles, Arrow Up/Down move between questions, Home/End jump to the first/last. Closed answers are inert. For an in-app collapsible list use Accordion.
Keyboard interactions
| Key | Action |
|---|---|
| EnterorSpace | Opens or closes the focused question. |
| ArrowDownorArrowUp | Moves focus to the next or previous question, wrapping at the ends. |
| HomeorEnd | Moves focus to the first or last question. |
| Tab | Moves to the next question, or into links in the open answer. |
Accessibility
- The section is labelled by its
<h2>; each question is a<button>inside an<h3>witharia-expandedandaria-controls. - Each answer is a
role="region"labelled by its question and isinertwhile closed. - The plus icon is
aria-hidden. Its turn and the answer's height and fade transitions are switched off withmotion-reduce:transition-none.
Frequently asked questions
Are closed answers still in the HTML for search engines?
Yes. Every answer is rendered and collapsed with a grid-template-rows transition, and closed ones are inert, so the text is in the server HTML but cannot be focused. Add FAQPage JSON-LD yourself if you want rich results; the block does not emit it.
Can an answer contain links?
Yes, a takes any React node. Links in a closed answer are skipped by Tab because the panel is inert, and they become reachable when it opens.
How do I start with all questions closed?
Pass defaultOpen={null}. The default is 0, which opens the first question. Only one question is open at a time.
Dependencies
npm
Built from