shadcn.io is not affiliated with official shadcn/ui
Expandable Sections FAQ Block for React
A two-level FAQ for a photo-book shop: an accordion of three sections whose panels each hold an accordion of questions, with a summary of how many of each.
Installation
Overview
An expandable-sections FAQ for React with Base UI. Under a centred header and a summary of how many sections and questions there are, one column holds an accordion of sections; each section opens to a tinted panel with a second accordion of its questions, indented under it. The first section starts open with its first question showing. The outer accordion opens one section at a time and each inner one one question at a time, independently. It is built from Accordion, Badge and Guides, with CSS for the entrance and your theme's tokens for every colour. For product pages and help centres with enough questions to need chapters.
FAQ
How do I change the sections and questions?
Edit SECTIONS at the top of the file: each section has an id, a title and its questions, each with an id, the question and its answer. The counts in the summary and on each section are derived. FIRST_SECTION and FIRST_QUESTION name what is open on load; set them to ids that don't exist to start with everything closed.
How do the two levels behave?
The outer accordion keeps one section open at a time. Each section has its own inner accordion, which keeps one question open at a time and remembers it while its section is closed, so closing and reopening a section doesn't lose your place.
Are the closed answers in the page's markup?
Yes. The Accordion takes hiddenUntilFound, so every closed answer stays in the markup as hidden="until-found", and the browser's find in page opens the one that holds a match.
How does it work with a keyboard and a screen reader?
Every section and every question is a button inside an h3 under the block's h2, because the catalog's Accordion fixes its heading level; Enter or Space opens and closes it, and the button says whether it's expanded.
Tab moves from button to button, and there are no arrow-key shortcuts.
Related
- Pro
Collapsible Groups FAQ
Accordion listsA grouped FAQ for a grocery-delivery service: four topic bands that collapse as a whole, each holding its questions as always-visible answers, the first two open.
- Pro
Accordion FAQ
Accordion listsA side-header FAQ for a web analytics tool: the title, one sentence and a contact prompt beside seven questions in an accordion, behind a split divider.
- Pro
Categorized FAQ
Topics and filtersA topic-tabbed FAQ for a bookkeeping app: a compact header, a band of line tabs with a count on each, and one accordion per topic.
- Pro
Dual Column Accordion FAQ
Accordion listsA two-column FAQ for a pottery studio: a start-aligned header, then two independent accordions of four questions side by side, behind a split divider.
- Pro
Icons FAQ
Accordion listsA cleaning-service FAQ built to be scanned: an icon tile on each question and three short answer lines led by a check, a clock and a shield.
- Pro
Compact FAQ
Accordion listsA dense FAQ for ski-lift passes: ten tight accordion rows with small type and one-sentence answers in a narrow framed list, a chevron at the start of each row.