shadcn.io is not affiliated with official shadcn/ui
Highlighted Question FAQ Block for React
A FAQ for boat winter storage that leads with its one most-asked question as a raised card in a card, key phrases highlighted, above five accordion rows.
Installation
Overview
A highlighted-question FAQ for React with Base UI. A title and one sentence sit above a card in card: a muted shell with + marks on its corners wraps a raised panel that is light on a light page and dark on a dark one, holding a "Most asked" badge, the question as a large heading, its answer with the key phrases marked as if with a highlighter, and a link to the full checklist. Below it, five more questions run rail to rail as hairline rows under a rule with + marks, closed until opened, and the last row ends the block. 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 Highlight Text, Badge, Accordion and Guides, with CSS transitions and your theme's tokens for every colour. For product pages where one question outweighs the rest and its answer should be on the page without a click.
FAQ
How do I change the featured question and its highlights?
The featured question and its answer are written in the markup of the card, so edit them there. Each highlighted phrase is a Marked component with its text; the words around them are plain. Keep to three or four short phrases that someone skimming would want to catch: marking half the sentence marks nothing. The five rows below come from QUESTIONS at the top of the file.
How is the highlight drawn, and is it readable?
The marker is the theme's foreground colour at 12%, so it's a light grey wash in a light theme and a lighter one in a dark theme, and the marked text switches to full foreground. Contrast stays well above the AA minimum in every preset and the page's text selection and find in page work as usual: the marked words are real text. It draws across each phrase once, a short moment after the page loads.
What happens with reduced motion?
The highlight is simply there, with no drawing, and the entrances are off, so the first screen shows the finished card. The rows' plus turns into a cross as a row opens, without animating. The answers also open and close at once, with no height animation.
Are the closed answers in the page's markup?
The featured answer is always on the page. For the rows below:
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 answer that holds a match.
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
Glossary Tooltip FAQ
Ways to revealA FAQ for a rooftop-solar installer where technical terms inside the answers are dotted-underlined buttons that open a one-line definition.
- Pro
Typewriter FAQ
Ways to revealA FAQ for a print-on-demand zine press: a card in card of six rows whose answers type themselves out the first time a question opens, then stay put.
- Pro
Testimonial FAQ
Proof and freshnessAn FAQ for a podcast studio where each of five questions brings its own customer quote, shown in a framed panel beside the open question.
- Pro
FAQ with Call to Action
Contact and signupAn FAQ whose answers end in the next step, for a clinic scheduling tool: six accordion rows, each open answer closing with a button that fits it, the first one a Shine Button.
- Pro
Minimal FAQ
Cards and gridsA type-forward FAQ for a stationery brand: six questions in large type with their answers on show in a definition list, no cards or row lines, and one contact link.