Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Difficulty FAQ Block for React

An FAQ for a coding school where every question has a level: a three-bar glyph and a badge on each row, and a level filter with counts beside the list.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A difficulty FAQ for React with Base UI. The start column holds the title, one sentence and a level filter (All levels, Beginner, Intermediate, Advanced), each with its count and, for the levels, a three-bar glyph; the end column holds eight questions behind a split divider. Each row leads with the same glyph and the level as an outline badge, and opens with a plus that turns into a cross. Choosing a level filters the list in place and a polite line says "Showing 3 of 8 questions"; the list keeps its height, so the page doesn't move. On a phone the filter is a row that scrolls sideways above the questions. It's built from Accordion, Segment Group, Badge and Guides, with CSS transitions for the entrance and your theme's tokens for every colour. For tutorial, course and docs pages whose questions span beginners to experts.

FAQ

How do I change the levels or a question's level?

Edit LEVELS (an id, a label and the number of bars, one to three) and give each entry in QUESTIONS the level id it belongs to. The filter, its counts, the row glyphs and the "Showing" line are all built from those two lists. Add a fourth level by adding an entry and another height to BAR_HEIGHTS.

How does the filter behave?

It's a Segment Group: Tab moves into it, the Left and Right arrow keys move between the options and choose one, and the list changes at once. The list is rendered from the filtered questions, and a polite status line announces the count. The list box has a minimum height, so filtering to a short list doesn't pull the next block up the page. The open question stays open if it survives the filter.

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 eight, and the browser's find in page opens the answer that holds a match.

Is the level shown by more than shape?

Yes. The glyph is decoration and is hidden from assistive technology; the level is always a word in the badge ("Beginner", "Intermediate", "Advanced"). The glyph uses foreground weights, full strength for the bars that count and a faint tone for the rest, so it reads in any theme.

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 them all. 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.

How does it fit on a phone?

The filter sits under the title as one row that scrolls sideways, and the level badge moves under each question. At sm the badge sits at the start of the row, and from lg the filter turns into a column in the start side. Nothing else scrolls sideways at 320 pixels.

  • Pro

    Topic Select FAQ

    Topics and filters

    A short FAQ for a bike-share with a topic Select at the end of its header: choose a topic and its questions fill the rows below, or choose All topics for all twelve.

  • Pro

    Categorized FAQ

    Topics and filters

    A topic-tabbed FAQ for a bookkeeping app: a compact header, a band of line tabs with a count on each, and one accordion per topic.

  • Pro

    Multi Select FAQ

    Topics and filters

    A topic-chip FAQ for an outdoor-gear rental: any number of chips can be on, and the list shows the union of their questions, with a live count.

  • Pro

    Tags FAQ

    Topics and filters

    A tagged FAQ for a children's book club: a side header with a tag cloud, and questions that carry their own tag buttons, both filtering the same list.

  • Pro

    A searchable FAQ for a notes app: a start-aligned header, a band with a full-width search field and a live count, and ten questions that filter as you type, open every match and mark the matched words.

  • Pro

    A vertical-tabs FAQ for a transit app: a rail of five topics with an icon and a count each, beside the open topic's accordion, behind a split divider.