Skip to content

Rating

Free

Give a score with stars, in whole or half steps. A display part shows any score, such as 4.3 of 5, with no input.

  • Base UI
  • Motion
  • React 19
  • Tailwind CSS 4

Added Nov 8, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

Render one RatingItem for each star, and show the average next to it with RatingDisplay, which no one can change.

stay-rating.tsx

Rating

<div>
PropTypeDefaultDescription
childrenReactNode—RatingItem parts. Leave it out to get max items.
size"default""lg""sm"—
classNamestring—
valuenumber | null—The score, or null for no score. Controlled.
defaultValuenumber | nullnullThe first score when uncontrolled.
onValueChange—Runs on each change, also on a clear (null). Call eventDetails.cancel to stop it.
maxnumber5The number of stars.
step0.5111: whole stars. 0.5: half stars, two radios per star.
clearablebooleanfalseA press on the current score clears it to null.
iconIconStarIconThe icon of a star: any Phosphor icon (HeartIcon); it draws in its fill and regular weights.
getItemLabelstarLabelThe accessible name of each choice. Default: "1 star", "2.5 stars".
glowboolean—A soft halo on the filled stars (glow, @gelatin-ui/glow). Default: false.
From Base UIRadioGroupBase UI docs
disabledbooleanfalseWhether the component should ignore user interaction.
readOnlybooleanfalseWhether the user should be unable to select a different radio button in the group.
requiredbooleanfalseWhether the user must choose a value before submitting a form.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

RatingItem

<span>
PropTypeDefaultDescription
classNamestring—
valueRequirednumber—The number of the star, 1 to max. With step={0.5} its halves are value − 0.5 and value.
From Base UIRadio.RootBase UI docs
disabledboolean—Whether the component should ignore user interaction.
requiredboolean—Whether the user must choose a value before submitting a form.
readOnlyboolean—Whether the user should be unable to select the radio button.
...props<span> attributes—Every other attribute goes to the <span>, with a ref.

RatingDisplay

<span>
PropTypeDefaultDescription
size"default""lg""sm"—
valueRequirednumber—The score to show, any fraction (4.3). It is clamped to 0 to max.
maxnumber5The number of stars.
iconIconStarIconThe icon of a star, as on Rating.
glowboolean—A soft halo on the filled stars (glow, @gelatin-ui/glow). Default: false.
...props<span> attributes—Every other attribute goes to the <span>, with a ref.
  • Use Rating when people set a score: a review, a feedback form.
  • Use RatingDisplay to show a score that no one can change. It takes any fraction, such as 4.3.
  • Use step={0.5} for half stars.
  • Use clearable when people can go back to no score.
  • Use icon for another shape, such as a heart.
Arrow RightorArrow DownMoves to the next higher score and chooses it. With step={0.5}, it moves by half a star.
Arrow LeftorArrow UpMoves to the next lower score and chooses it.
SpaceWith clearable, on the current score: clears the score.
TabLeaves the group.

Each star is a radio, and getItemLabel translates its name. The default is "3 stars".

RatingDisplay takes no focus. Show the number next to it, so the score reads without the icons.

On a coarse pointer each radio is 44px tall.

Hover
hover · 150ms · ease-out (0, 0, 0.2, 1) · the stars up to the pointer show at 60%
Press
press · 100ms · ease-out (0, 0, 0.2, 1) · the pressed star scales
  1. AddedRating.
Open the release