Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Search Reviews Block for React

A search-first review section for a ceramic pot: a large field with suggestions mined from the reviews, per-star result chips that follow the query, a best-match or newest order, and results with every match marked.

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

Search-first reviews for React with Base UI, for the Kilnwell Hearth Pot, a fictional ceramic casserole. A centred header with the title and one sentence (the average and the count, worked out from the reviews) sits over a band under a rule. The band opens with a large search field: a magnifier, a "/" key hint that really does focus the field from anywhere on the page that isn't already a text field, and a button that clears it once you type. Typing opens a popup of suggestions, the words the reviews actually use with the number of reviews that use each ("handle (7)"), mined from the typed reviews when the file loads. Under the field, one chip per star rating (and "All") shows how many results each would give for the current query, and a segment orders the matches by best match or newest. A live line says "Showing 4 of 9 reviews for “handle”". The matches are ruled rows, four at a time, with every occurrence of the query in the title and text marked by the catalog Search Highlight Text, which ignores case and accents. When nothing matches, an empty state says so. It's built from Autocomplete, Input Group, Kbd, Toggle Group, Segment Group, Search Highlight Text, Rating, Avatar, Empty and Guides, with CSS transitions only.

FAQ

How do I use my own reviews?

Replace REVIEWS at the top of the file. Each review has an id, name, rating from 1 to 5, an ISO date, a title, a body, a helpful count and a verified flag. The suggestions are mined from the same list: every word of four letters or more that three or more reviews use, minus the short list in COMMON, most used first. The average, the per-star counts, the matches and the order are all worked out from it too.

What counts as a match, and what is "best match"?

A review matches when its title or text contains the whole query, ignoring case and accents (so "glaze" finds "Glaze"). Best match counts how often the query occurs, with a title hit worth three; with an empty query it lists the most helpful first. Ties go to the newest review. The marks come from the same comparison, so the rows you see are exactly the ones the count describes.

Do the star chips filter or only count?

Both. Each chip's number is how many matches that star rating has for the current query, and pressing a chip narrows the rows to it. Type a new word and the numbers change at once. "All" is always available, and the live line says how many reviews match with the star you chose.

Why doesn't the page move as I type?

An unseen copy of the four tallest reviews sits in the same grid cell as the live rows and the empty state, so the cell is always as tall as a full list. The star chips and the order segment sit in one row that scrolls sideways on a phone, and the status line has a fixed height.

How do I use it from the keyboard?

Press "/" to jump to the field, type, and use the arrow keys to move through the suggestions; Enter puts the highlighted word in the field. Escape closes the popup. Highlighting a suggestion never rewrites what you typed. Tab goes on to the star chips and the order segment, which use the arrow keys.

Does it work right to left?

Yes. The field, its icons, the chips and the rows follow the page's direction, stars are mirrored so they fill from the start, and the counts, dates and the quoted query are isolated so their characters keep their order.

  • Pro

    Keyword Mentions Reviews

    Insights and trends

    A topic table for sofa reviews: mentions found by keywords, a share bar and the average rating of the reviews that mention each topic against the overall average, sortable, with the matching reviews under it.

  • Pro

    Tag Cloud Reviews

    Insights and trends

    A word cloud for coffee-bean reviews in a framed figure: eighteen words sized by how often the reviews say them, and a keyword-in-context list that shows every mention of the chosen word with who said it.

  • Pro

    Advanced Sort Reviews

    Filter and search

    A filter panel for tent reviews: a sort key, an order, star pills, a recency segment and a verified Switch beside the matching reviews, with removable chips, a live count and a bottom Sheet on phones.

  • Pro

    Filter Sort Bar Reviews

    Filter and search

    A toolbar band for rain-jacket reviews: a rating Select, a Verified toggle, a date Popover and a sort Select, a live count with removable chips, and the matching reviews as ruled rows.

  • Pro

    Search Testimonials

    Filter and search

    A search box in the header row that filters eight customer quotes as you type and marks the matched words, with a result count, Escape to clear and an empty state, in a band of hairline-ruled rows.

  • 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.