shadcn.io is not affiliated with official shadcn/ui
Raised Panel FAQ Block for React
A card-in-card FAQ for a sleep-tracking wearable: a start-aligned header over one raised panel, that follows the page theme, holding seven accordion rows and a contact foot.
Installation
Overview
A raised-panel FAQ for React with Base UI. A start-aligned title and sentence sit above a tinted shell with + marks on its corners, which holds a raised panel with a soft shadow and a ring. The panel holds seven accordion rows divided by hairlines, and a foot band, a step darker, with a contact line and a ghost link. The emphasis comes from the lift, not from a colour: the panel is never forced dark, so it's light on a light page and dark on a dark one. Each row's small square plus fills in and turns into a minus as it opens. The page's rails and top rule come from the Guides spine, so the block lines up with its neighbours in a stack. It's built from Accordion, Guides and Button, with CSS transitions for the entrance and your theme's tokens for every colour. For product pages that want one framed, finished answer panel.
FAQ
How do I change the questions?
Edit QUESTIONS at the top of the file: each entry is an id, the question and its answer, one to three sentences. OPEN_QUESTION names the one that's open on load; set it to an id that doesn't exist to start with all of them closed. Keep it to about eight. One answer is open at a time.
Add multiple to the Accordion to let several stay open.
Is the panel dark?
No. It follows your theme: the shell is a tinted step off the page, and the panel is your card colour with a shadow and a ring, so it reads as lifted in a light theme, where card and page are nearly the same, and in a dark one. No dark scope is set anywhere, so nothing is a fixed colour.
Are the closed answers in the page's markup?
Yes. Each Accordion takes hiddenUntilFound, so every closed answer stays in the markup as hidden="until-found": search engines see all 7, and the browser's find in page opens the answer that holds a match.
How does it work with a keyboard and a screen reader?
Each question is a button inside its own h3 under the section's h2, so a screen reader's headings list shows every question. Tab moves from question to question, Enter or Space opens and closes one, and the button says whether it's expanded. The open answer is labelled by its question. Tab then continues to the contact link in the foot.
Where does the link go?
It is a ghost button (href="#"): point Write to the sleep team at your help desk or a mailto: address. The block has no other button.
The button renders the link it's given with render, with nativeButton={false}.
Related
- 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
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.
- Pro
Numbered FAQ
Accordion listsA numbered FAQ for a wine club: eight accordion rows from rail to rail, with a margin of tabular numerals, 01 to 08, behind a hairline; the open row's numeral turns to full strength.
- Pro
Centered Email Capture CTA
Forms and captureA call to action between solid rails that follows the page theme, in a card in card with a two-step email capture: an email field and a Shine Button, then a six-digit code that verifies on the sixth digit and turns into a confirmation in the same space.
- Pro
Pricing With FAQ
Proof and guaranteesPlans answered by the pricing FAQ for an e-commerce builder: a compact plan list, a row each with its name, price and call to action, beside an accordion of six questions with the first one open, in one ruled band.
- 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.