---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Rating

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

Pro. Its export: `Rating`.

## Try it

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.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-rating.json --yes
```

```text
Add the Goop Rating to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
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

### Rating: every option

```tsx
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`, `optional` and `disabled` do 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 no `aria-label` names 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: `true` for "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, `empty` itself).
- 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

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

## Related

- [Color picker](/themes/meadow/components/color-picker): A painted area and channel sliders that choose one colour.
- [File upload](/themes/meadow/components/file-upload): A drop zone or a button to choose files, for attachments, an import or a photo, with a list of the chosen files.
- [Calendar](/themes/meadow/components/calendar): A month always in view, to choose a date or a range of dates.
- [Date picker](/themes/meadow/components/date-picker): A field that opens a month to choose one date, typed or picked.
