Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Summary Header Reviews Block for React

The header of a product's reviews page: the product name, a Write a review button that opens a real form in a dialog, and a three-cell band with the score, the share that recommend it and five distribution rows.

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 reviews page header for React with Base UI, for the Ruckfield Commuter 28, a fictional 28-litre backpack. The title is the product name, with one sentence and the Shine Button, Write a review, which opens a dialog with a real form: a star rating you can set with the arrow keys and name through its own words (Poor to Excellent), a text box, checks when you submit (a rating, at least 20 characters) with the error under its field and focus sent to the first problem, and a thanks that says plainly that nothing was sent. Under a rule, a band of three cells between hairlines holds the summary of all 52 reviews: the score beside read-only stars and the count, the share that would buy it again, and five distribution rows, each with a bar, a count and a percentage. Every figure is worked out from the typed counts at the top of the file. On a phone the cells stack and the button sits under the sentence. It's built from Dialog, Field, Textarea, Rating, Guides, Button and Shine Button.

FAQ

How do I put in my own ratings?

Edit TALLY (how many reviews gave each star rating) and RECOMMENDED (how many would buy it again) at the top of the file. The total, the average to one decimal (by whole-number maths), the stars drawn to the nearest half, the recommend share and each row's percentage by the largest remainder method, so the five rows always add up to 100, are all worked out from them.

Is the review sent anywhere?

No. The form is local state: it checks the rating and the text, then shows a thanks that says "Your review shows here only; this page does not send anything." Close the dialog and open it again and the form starts empty. To keep reviews, post rating and review to your own endpoint from the submit handler and show the thanks when it answers.

Where does focus go?

When the dialog opens it follows your library's own rule. On a failed submit, focus moves to the first field with a problem: the first star when the rating is missing, the text box when the review is too short. After a good submit it moves to the thanks, and closing the dialog returns focus to Write a review.

Why are the display stars hidden from screen readers?

They're the catalog Rating, read-only, inside an inert, aria-hidden wrapper: they only draw the average, and the figure beside them says it. The form's rating is the same component, not read-only, and each star is named ("3 of 5, Good").

How does it fit on a phone?

The three cells stack with a hairline between them, the header's button sits under the sentence, and the dialog fits the screen. Nothing scrolls sideways at 320 pixels.

  • Pro

    A review summary for a carry-on suitcase whose star rows filter the reviews: the average, the count, the share that would recommend it and a five-row distribution, beside the four most helpful reviews with a Helpful vote each.

  • Pro

    A review score with its sum shown: a large rolling figure with stars beside a list of the arithmetic, and a two-way switch between a simple average and one that counts unverified ratings at half.

  • Pro

    The whole review form on one page for a cast-iron pan: a named star rating, a title and text with live counts, pro and con tag lists, a recommend choice, photo names, and a sticky checklist with a progress bar.

  • Pro

    The review summary that lives in a product page's sidebar, shown at its real 20rem width beside a greyscale sketch of the page: score, five mini bars, the most mentioned words, the latest review and a link to all of them.

  • Pro

    A rating distribution for a hiking boot: five ruled rows of bars, counts and shares, a Bars and Table switch, and a readout of mean, median, mode and the share rated four or more.

  • Pro

    A one-tap star rating for a phone case: the tap rates at once, the product's average is worked out again with yours counted in, Undo takes it back, and Add a comment opens a text box with a real check.