shadcn.io is not affiliated with official shadcn/ui
Popularity Bars FAQ Block for React
A 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.
Installation
Overview
A popularity FAQ for React with Base UI. A start-aligned header sits over six accordion rows that run from rail to rail under a rule with + marks, ordered by how often each is read, and a column header says so: "Most read first" at the start, "Reads this quarter" at the end. Every row has a count column at its end ("1.9k reads") and, under its question, a thin bar as long as the count is against the most-read row. The order, the bars and the counts all come from one list of numbers, and nothing needs a script. It's built from Accordion and Guides, with CSS transitions for the entrance and your theme's tokens for every colour. For documentation homes and support pages where showing what others read first guides the rest.
FAQ
Where do the counts come from, and how do I change them?
Edit ENTRIES at the top of the file: each entry is an id, the question, its answer and reads, a plain number for the quarter. They can be in any order: the block sorts them, most read first, and MOST_READS (the largest) sets the bar's full length. To use real figures, fetch the numbers from your analytics on the server and pass them in as reads; the label, the order and the bars follow.
Why both a bar and a number?
The number is the information and the bar is a glance: it's hidden from screen readers, because the count beside it says the same thing in words. Each bar is as long as its count is against the top row, so the first is always full length. The count is formatted by readsOf ("1.9k", or the whole number under a thousand) and wrapped in bdi, so a right-to-left layout keeps it in reading order.
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, and its name includes the count ("How hot should the water be? 1.9k reads"), so a screen reader hears the popularity with the question. One answer is open at a time.
Tab moves between the questions; the arrow keys don't move between questions on this base.
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": search engines see all six, and the browser's find in page opens the answer that holds a match.
Related
- Pro
Votes FAQ
Votes and reactionsA community FAQ for a product forum: six accordion rows with a vote rail at the start of each, an up arrow, a score and a down arrow, one vote per answer that can be taken back.
- Pro
Rating FAQ
Votes and reactionsA reverse-split FAQ for a recipe app: seven rows that each show an average rating, with a one-to-five scale at the foot of every open answer and the header beside the rows.
- Pro
Bookmarks FAQ
Reading and sharingA 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.
- Pro
Last Reviewed FAQ
Proof and freshnessA FAQ for a returns portal that shows how recently each answer was reviewed, with four dots and words in a mark column, and a switch to keep this quarter's.
- 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
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.