Rating
betaA star rating input with half stars, a springy hover preview and a burst on the chosen star — or a read-only display of any fraction.
- Forms
- 1 file
- 1 npm package
- Accessibility notes
pnpm dlx @dowel-ui/cli add ratingnpm packages installed: class-variance-authority.
import { Rating } from "@/components/ui/rating";Default
Half Stars
Read Only
Sizes
Custom Icon
Controlled
Disabled
<Rating>
| Prop | Type | Default |
|---|---|---|
allowHalfLets each star be chosen by half, by where the pointer sits inside it. | boolean | false |
defaultValueInitial value when uncontrolled. Default 0. | number | 0 |
disabled | boolean | false |
getLabelAccessible name of each option. Default "1 star", "2.5 stars". | (value: number, max: number) => string | defaultGetLabel |
iconA glyph to use instead of the star, drawn as an outline and a solid fill. | ReactNode | — |
maxHow many stars. Default 5. | number | 5 |
nameSubmits the value with a form under this name. | string | — |
onValueChangeCalled when a star (or half star) is chosen by pointer or keyboard. | (value: number) => void | — |
readOnlyShows the value as an image named "3.5 out of 5"; nothing can be chosen. | boolean | false |
size | "sm" | "md" | "lg" | "md" |
valueControlled value; 0 is no rating. | number | — |
Plus every attribute of <div> except defaultValue, onChange, children.
10/10
checks passed
- Tested — passes
- axe assertion — passes
- Keyboard tested — passes
- Storybook examples — passes
- Accessibility documented — passes
- Semantic tokens only — passes
- Motion from tokens — passes
- className merged — passes
- Visible focus — passes
- No fixed widths — passes