Rating

Stars that preview on hover, fill smoothly and pop in a cascade when you pick one. Half stars and keyboard included.

Inputs
Great

Playground

Tweak the props, the preview and the code follow.

Props
5
import { Rating } from "@/components/ui/rating"

<Rating defaultValue={3} size="lg" />

Installation

npx @plumsydev/plum-ui add rating

Usage

import { Rating } from "@/components/ui/rating"
<Rating defaultValue={4} />

Examples

Half stars

out of 5· hover the left half of a star

Review form

A read-only summary next to an interactive rating.

4.6

2,184 reviews

5
4
3
2
1

Write a review

How was the onboarding?

API Reference

Rating

PropTypeDefault
value

Controlled value.

number—
defaultValue

Initial value when uncontrolled.

number0
onValueChange

Clicking the current value resets to 0.

(value: number) => void—
max

Number of stars.

number5
allowHalf

Pick halves by pointing at the left side of a star.

booleanfalse
readOnly

Display only, accepts fractional values.

booleanfalse
size

Star size.

"sm" | "default" | "lg""default"
icon

Replace the star with any icon.

(className: string) => ReactNode—

Notes

  • Behaves like a slider for assistive tech: arrow keys step, Home and End jump to the ends.