Rating
ProA 1-to-N star rating built on Radix RadioGroup: roving focus, arrow keys and hover preview for free. Active stars render solid, the one place the DS opts out of its outline-only rule, and half stars read cleanly.
Installation#
Usage#
The preview is yours to explore. Its code comes with a Pro license, paid once and used in every project.
Have a license? Unlock it here
Sizes#
sm (16px), md (20px), and lg (28px) line up with the rest of the control scale.
Tones#
tone recolors the active glyph, independent of the icon: amber (default) is the vivid review-gold for stars, and red is the love-red that suits a Heart. Both ride dedicated rating tokens, brighter than the warning status hue.
Variants#
filled (default) is the classic solid-star look: the active glyph renders at the fill weight, the rest stay outline. outline keeps the DS rule, drawing the active star as a tinted outline instead.
Read-only & fractional#
readOnly renders a static display and accepts fractional values: an average like 4.3 shows a partly-filled star via the clip overlay.
Custom icon & length#
Swap the star for any Koala icon with icon, and set the scale length with max. Recolor the fill with tone: amber (default review-gold) or red, which suits a heart. The icon follows the active variant: solid by default, outline with variant="outline".
Disabled#
API reference#
Rating
Interactive, it wraps Radix RadioGroup.Root with one RadioGroup.Item per star; with readOnly it renders a static <div role="img">. Forwards native <div> props (except onChange, defaultValue and dir) and accepts className, merged last.
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | - | Controlled value. Whole numbers when interactive; fractional values (e.g. 4.3) render when readOnly. |
| defaultValue | number | 0 | Uncontrolled initial value. |
| onValueChange | (value: number) => void | - | Called with the new whole-star value when a star is selected. |
| max | number | 5 | Number of stars in the scale. |
| readOnly | boolean | false | Drops the RadioGroup for a static, fraction-capable display, labelled like "Rating: 4.3 of 5". |
| disabled | boolean | false | Disables every star and fades the row. |
| name | string | - | Form field name, passed to the underlying RadioGroup so the value submits with a form. |
| icon | Icon | Star | Any Koala icon component to use instead of the star (e.g. Heart). It follows variant: solid by default, outline with variant="outline". |
| aria-label | string | "Rating" | Names the group and builds each star's label, e.g. "Rating 3 of 5". |
| size | "sm" | "md" | "lg" | "md" | Star size: 16px, 20px or 28px. |
| variant | "filled" | "outline" | "filled" | filled draws the active glyph at the fill weight; outline keeps it a tinted outline. |
| tone | "amber" | "red" | "amber" | Hue of the active glyph: review-gold, or the love-red that suits a heart. |
| Data attribute | Description |
|---|---|
| data-disabled | Set by Radix on the group and each star when disabled. |
| data-state | On each star: "checked" for the selected star, "unchecked" otherwise (interactive only). |