npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-rating.json --yesRating
ProA row of stars to give a score, or to show an average with halves, for reviews, testimonials and feedback, for React and Tailwind CSS. Part of Goop Pro.
What an agent sees
import { Rating } from '@/components/ui/goop/rating';
function VisitFeedback({ score, onScore }: { score: number; onScore: (next: number) => void }) {
return (
<div className="flex flex-col items-start gap-2">
<label htmlFor="visit-score" className="text-base font-medium">
How was your visit?
</label>
<Rating id="visit-score" name="score" value={score} onValueChange={onScore} />
<div className="flex items-center gap-2 text-sm text-muted-foreground">
<Rating readOnly size="sm" value={4.5} count={128} /> · North field crew
</div>
</div>
);
}Click a star (its start half for a half with half stars on), or Tab in and use the arrows, Home, End or a number key; Backspace clears. Look puts the stars in a form’s field, an average in a card’s line (Size sm as a card shows it), or a row beside Send and a filter. Switch the sizes, the value words, read-only, disabled and invalid. The score is kept in the page only: nothing is sent, and the filter beside it filters nothing.
When to use
- A row of stars to give a score, or to show an average with halves, for reviews, testimonials and feedback.
- Also called: star rating.
Installation
Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Rating on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-rating.json --yesAdd the Goop Rating to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { Rating } from '@/components/ui/goop/rating';
function VisitFeedback({ score, onScore }: { score: number; onScore: (next: number) => void }) {
return (
<div className="flex flex-col items-start gap-2">
<label htmlFor="visit-score" className="text-base font-medium">
How was your visit?
</label>
<Rating id="visit-score" name="score" value={score} onValueChange={onScore} />
<div className="flex items-center gap-2 text-sm text-muted-foreground">
<Rating readOnly size="sm" value={4.5} count={128} /> · North field crew
</div>
</div>
);
}- Fits: record, list: row.
- Also known as: StarRating, Stars, ReviewScore, ScoreInput, RatingInput.
- Ask for a 1-to-5 score with Rating under its own label and show an average with Rating readOnly size sm (a testimonial's or a review's stars); use Slider for continuous values.
- height, width, gap, corner, text: add no class for these.
API reference
- Each option with its sentence: rating--options.md
- State: value (value / defaultValue / onValueChange)
- data-slot values (to select a part by): rating, rating-half, rating-icon, rating-indicator, rating-item, rating-list, rating-radio, rating-value
Rating: every option
import { Rating } from '@/components/ui/goop/rating';Options
- value?: number — The chosen score, 0 for not rated, for a rating its caller holds (with
onValueChange); read-only, the average. - defaultValue?: number = 0 — The score at first render, for a rating that holds its own (default 0: not rated).
- onValueChange?: (value: number) => void — Called with the new score when a person chooses a star, or with 0 when they clear it.
- max?: number = 5 — How many stars (default 5).
- readOnly?: boolean = false — Show the value only: one image named "Rated 4.5 out of 5", halves drawn (rounded to the nearest half), no stop;
allowHalf,optionalanddisableddo nothing on it. - size?: 'sm' | 'md' | 'lg' = 'md' —
md(the default): 20 px stars in 28 px cells;sm: 14 px stars 2 px apart, read-only beside 12 px words;lg: 24 px stars in 32 px cells beside 13 px words, a rating that is the page's question. - allowHalf?: boolean = false — Half stars may be given: a radio per half, the pointer on a star's start half gives the half, the arrows move by a half and Home starts at a half star.
- optional?: boolean = true — The score may be none: a second press on the chosen star, Backspace or Delete clears it (default true).
- name?: string — The radios' name, sent with the form (nothing is sent while not rated); a name of its own when left out.
- disabled?: boolean = false — Every star off: none takes the focus, a press or a key; the stars and the number faded once.
- label?: string — The rating's name where no
<label htmlFor>and noaria-labelnames it. - starLabel?: (value: number, max: number) => string — Each star's name for a reader (default "1 star", "n stars", then its value word with
valueLabels). - valueLabels?: boolean | readonly string[] — Words for the scores, shown after the stars in place of the number and said with each star:
truefor "Poor", "Fair", "Good", "Very good", "Excellent" (five stars), or one word per star. - showValue?: boolean = true — Whether the value stands after the stars (default true): the score ("4", "4.5") or its word; at 0 an en dash named
empty(read-only,emptyitself). - empty?: string = 'Not rated' — The words for not rated (default "Not rated"): interactive, the name and the title of the en dash the value shows in their place, so the value keeps a score's width; read-only, shown after the stars.
- count?: number — Read-only: how many ratings the average holds, written after it in brackets ("4.5 (128)").
- State: value (value / defaultValue / onValueChange)
Keyboard
| Key | What it does |
|---|---|
| Tab | Move to the chosen star (the first when not rated), then out of the group |
| ArrowRight ArrowUp | Choose the next star (the next half with allowHalf), wrapping |
| ArrowLeft ArrowDown | Choose the previous star (the previous half with allowHalf), wrapping |
| Space | Choose the focused star |
| Home End | Choose the lowest score (one star, or a half with allowHalf) or the highest, the focus with it |
| 1-9 | Choose that many stars, the focus with it (a number past the stars does nothing) |
| Backspace Delete | Clear the score |
Accessibility
- The native element answers the keyboard.
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| disabled | the prop disabled |
| invalid | the attribute aria-invalid |
Notes for AI
Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.