shadcn.io is not affiliated with official shadcn/ui
Review Submit Dialog Block for React
A tea shop's product listing with a review dialog shown open: three star ratings that roll into one overall, how it was brewed, a title, a review with a length bar, writing tips and a buy-again choice.
Installation
Overview
Let buyers rate what matters and get one honest number out of it, with this review dialog for React with Base UI. It opens from the Sencha tin on Steepwell, a loose-leaf tea shop: the page's header holds an outline Write a review Button, and the product listing, a tin drawn from three shapes with a rating row, a price and an Add to basket, is drawn under a soft scrim inside a hairline frame with a plus mark on each corner. The Dialog holds three Rating rows, Aroma, Flavour and Value, five stars each in the foreground colour, and beside them an Overall tile that is worked out, not typed: the mean of the three to one decimal ("4.3") with a read-only half-star row. Under them are how you brewed it, a Toggle Group of Hot, Iced and Cold brew, a Segment Group for Would you buy it again, a title Input, a review Textarea that needs 40 characters and says how many more, and a Writing tips button. Post review, the only Shine Button, waits for the three ratings and the length, then puts "Your review: 4.3 (pending, in this demo)" on the drawn listing. For preview the dialog is drawn open in place when the page loads; the header button opens the real Dialog, with the same form and the same state. For shops, marketplaces, app stores and any product that earns more than one score.
FAQ
Why is the dialog already open, and what do I keep?
So you can see it without a click. On load the dialog is a copy drawn in place over the page: a native dialog element that isn't modal, so nothing is trapped, hidden or focused, and the page around the preview keeps working. The Write a review button opens the real Dialog, modal, with its focus trap, Escape and focus return, and the copy stays closed until a reload. Both show the same ReviewFields component and share the block's state, so stars set in the copy are there in the real one. In your app keep the Dialog and drop the copy: the "in-place" state, the scrim and the dialog element inside the frame.
How is the overall worked out, and what does the star row show?
The overall is the mean of the three ratings, in whole tenths so there is no floating-point drift (5, 4 and 4 make 13 over 3, so 4.3), and it shows only once all three are in; until then the tile says to rate all three. The read-only row of stars next to it rounds to the nearest half star, so 4.3 shows four and a half; the number is the exact figure and the stars are the picture. Each rating row is a group named for its criterion, and its stars are moved with the arrow keys; they are the foreground colour, not the warning tone the Rating defaults to.
What does the length bar do, and what do the writing tips do?
The review needs 40 characters (and stops at 500). The bar fills as you type and the words beside it say "Add 24 more characters" and then "Long enough", with a polite message once when the limit is crossed. Writing tips swaps two short tips into the line under the form, where the missing-requirements line normally is, so opening it never moves the dialog; the line comes back when you close it. Title, brew and buy again are optional.
What does Post review wait for, and what does it change?
All three ratings and the length. Until then the button is quiet but still answers a press: the reason is on the line under the form ("Rate the aroma to post.", "Add 24 more characters to post."), pressing says it in a polite message and puts focus on the first stars or the review field that needs it. Posting closes the dialog and the drawn listing's rating row gains "Your review: 4.3 (pending, in this demo)". The header button then reads Edit review and the dialog reopens on what you posted; Cancel and Escape drop anything you changed.
Does it post anything, and how do I wire it up?
No. A polite message says "Review posted for the Sencha tin, in this demo" and "Nothing was sent". In your app send the three scores, the choices and the text from post, and let the server compute and store the overall: the client's mean is for display. Say that a review is pending if you moderate, as here, and keep photos out unless you have a place to put them.
Is it accessible from the keyboard?
Yes. The real dialog is named by its title and described by its sentence, focus starts on the first stars, and Escape, Cancel and the close button all return focus to the header button. The trigger is passed to DialogTrigger through render, and the dialog is controlled with open and onOpenChange. The brew choices are a group you move through with the arrow keys, Writing tips is a button with aria-expanded and aria-controls, and one polite status message reports what changed. The copy shown on load moves no focus; Escape inside it, Cancel and its close button close it and put focus on the header button. On a phone the dialog's body scrolls under a footer that stays in view.
Related
- Pro
App Rating Dialog
Drawers and popoversA water tracker's Today screen with its rating drawer shown open over a drawn phone: five stars with a word each, then a branch, where four or five stars offers the store and one to three asks what could be better, with topics and a note.
- Pro
Full Write Form Reviews
Ask and writeThe 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
Weighted Category Ratings Reviews
Criteria and compareFive criteria as ruled rows with a bar, a score and a signed change against the previous quarter, and a Select that weighs them for everyday, commuting or gym use and re-derives the overall score.
- Pro
Feedback Form Dialog
Drawers and popoversA documentation page with a feedback card docked to its end and shown open: a kind, a message of up to 400 characters with a count, the page it is about, and an optional email that turns on when you let the team reply.
- Pro
Feedback Rating Dialog
Feedback and reportsA help desk's ended chat with a one-tap satisfaction dialog shown open: five drawn faces from very bad to great that record the score at once, then an optional comment with a question that fits the score.
- Pro
Contact Support Dialog
Feedback and reportsA shipments table with a support dialog shown open: a ticket form with a category, a priority and attached file names, and beside it up to three help articles picked by the category and the subject's words, each opening in place.