Rating

Forms

A five-star rating input with hover preview and click to rate.

Ratings capture opinion with a single interaction. Stars fill on hover, and the chosen value is reported to the parent on click.

npx shadcn@latest add rating

Basic usage

Controlled stars with a live score readout.

Preview
Live

Score: 3 / 5

tsx
1const [value, setValue] = useState(3)
2
3<Rating value={value} onValueChange={setValue} />

Custom size and scale

max controls the number of stars; size controls their pixel size.

Preview
Live
tsx
1<Rating max={10} size={12} />

With a label

Pair with Label for accessible rating fields.

Preview
Live
tsx
1<Label>Rate your experience</Label>
2<Rating value={4} />

API reference

All props of the underlying Base UI primitive are forwarded. The table below documents the Shelf-specific props.

PropTypeDescription
valuenumberThe controlled rating value.
onValueChange(value: number) => voidCalled when a star is clicked.
maxnumber= 5The number of stars.
sizenumber= 16The pixel size of each star.
disabledboolean= falseDisables rating interaction.