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 ratingUsage
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
API Reference
Rating
| Prop | Type | Default |
|---|---|---|
valueControlled value. | number | — |
defaultValueInitial value when uncontrolled. | number | 0 |
onValueChangeClicking the current value resets to 0. | (value: number) => void | — |
maxNumber of stars. | number | 5 |
allowHalfPick halves by pointing at the left side of a star. | boolean | false |
readOnlyDisplay only, accepts fractional values. | boolean | false |
sizeStar size. | "sm" | "default" | "lg" | "default" |
iconReplace 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.