shadcn.io is not affiliated with official shadcn/ui
Bookmarks FAQ Block for React
A side-header FAQ for a music-lessons platform: a star on every row, a framed Saved questions panel, and an All and Saved filter that shows only the rows you kept.
Installation
Overview
A bookmarking FAQ for React with Base UI. The start column holds the title, one sentence, an "All 7 / Saved 2" filter and, under them, a framed "Saved questions" panel; the end column holds seven questions behind a split divider that runs from the page's top rule to the block's end. A star at the end of each row saves it and turns to the text colour on the page colour (never the primary). The panel lists what you saved, each entry opens its row and moves focus to the question, and the filter shows only the saved rows, with an empty state and a way back to the full list. Saves live in memory, so nothing is stored. On a phone the panel follows the rows. It's built from Accordion, Toggle, Segment Group, Button, Badge and Guides, with CSS transitions for the entrance and your theme's tokens for every colour. For documentation and help centres where visitors return to the same few answers.
FAQ
How do I change the questions and what starts saved?
Edit QUESTIONS at the top of the file: each entry is an id, the question and its answer. SAVED_AT_START lists the ids that are already saved when the page loads (set it to an empty array for none), and OPEN_QUESTION names the row that's open on load. Keep the list to about eight; past that, a search or categories serve visitors better.
Are the saved questions kept?
Not yet: they live in the component's state, so a reload resets them to SAVED_AT_START. To keep them, write the saved array to local storage or your own endpoint when it changes, and read it back in an effect after mount so the server and the browser render the same first paint.
What do the entries in the panel do?
The question opens its row, switches the filter back to All if you were on Saved, and moves keyboard focus to the question; the cross takes the row out of your saved list. When nothing is saved the panel says so, and with the filter on Saved the list shows an empty state with a button back to the full list. The list keeps a minimum height, so taking a row out of Saved doesn't move what's below it, and a polite status line reads "Showing 2 of 7 questions, 2 saved".
Why is the accordion controlled?
The panel has to open a row, so the block holds the open row in state.
The Accordion takes value (an array of open ids) and onValueChange, and hiddenUntilFound keeps closed answers in the markup.
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. The star is a toggle button after its question in the Tab order, named "Save question:" and the question, and it says whether it's pressed. The filter is one group of two radio buttons named "Show questions", and the arrow keys move between them.
Tab moves between the questions and their stars; the arrow keys don't move between questions on this base.
How does it fit on a phone?
Below the lg breakpoint the header and the filter stack above the rows, which run from rail to rail under a rule with + marks, and the Saved questions panel follows the last row. A long question wraps and keeps its star and chevron at the end, and nothing scrolls sideways at 320 pixels.
Related
- Pro
Reactions FAQ
Votes and reactionsA start-aligned FAQ for a design-feedback tool: six rows whose open answers end in four reaction chips, each a face or a heart with a word and a count, plus running totals.
- Pro
Feedback FAQ
Votes and reactionsA centred FAQ for a scheduling app: seven accordion rows whose open answers end in a Was this helpful? foot with Yes and No, reason chips after a No, and a polite thank-you.
- Pro
Related Questions FAQ
Reading and sharingA cross-linked FAQ for a password manager: every answer ends in two related questions, and choosing one opens that row, scrolls to it and moves focus to its question.
- Pro
Popularity Bars FAQ
Votes and reactionsA FAQ for a tea shop ordered by how often each answer is read: a count column at the end of every row and a thin bar under each question, as long as its count.
- Pro
Collapsible Sidebar FAQ
NavigationA sidebar FAQ for a holiday-rental site: a topic rail with two collapsible groups and a live count, beside a filtered list, and a native select on phones.
- 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.