shadcn.io is not affiliated with official shadcn/ui
Highlighted Question FAQ Block for React Aria
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 React Aria. 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 catalog's Accordion still eases an answer's height over 200 milliseconds.
Are the closed answers in the page's markup?
The featured answer is always on the page. For the rows below:
React Aria keeps every closed panel in the markup as hidden="until-found", and the browser's find in page opens the answer that holds a match.