ComponentsSite blocks

Star rating

Stars for ratings. StarRating shows a value read-only: one role="img" named “Rated 4.5 out of 5”, half (or tenth) fills that start from the inline start, an optional average and review count (as a link to the reviews). StarRatingInput asks for one: a native radio group in a fieldset with a legend, one tab stop and arrow keys, every radio named (“4 stars”, “4.5 stars” with half steps), and it posts with the form. Hover and checked fills are CSS; there is no JS unless you pass onValueChange.

Native radios + :has() blocks/site/star-rating.tsx, styles/commerce.csstheme · material · accent · density · font
128 reviews52 reviews

Installation

$ pnpm add @vamos-ui/react

The whole kit as one package — get updates by bumping the version. Add the styles to globals.css: @import "@vamos-ui/react/styles.css";

Usage

import { StarRating, StarRatingInput } from "@vamos-ui/react/blocks";

<StarRating value={4.6} showValue count={128} countHref="#reviews" />

<form action={saveReview}>
  <StarRatingInput name="rating" label="How would you rate it?" allowHalf required />
</form>

Half steps halve the click target of each radio; keep size="lg" when you use allowHalf on touch screens.

The stars are monochrome (text-fg). Set a colour with className on StarRating, e.g. text-accent-ink.

Examples

Input (controlled)

value + onValueChange; the legend is the question, the description sits under it.

How would you rate the Tide mug?

Your rating appears next to your review.

No rating yet.

Half steps, sizes, disabled

allowHalf puts two radios on each star. Uncontrolled with defaultValue; disabled disables the fieldset.

Sound
Comfort
Build quality (locked)

Turkish, German, Arabic (RTL)

commerceLabelsTr / De / Fr / Es / Ar; numbers follow the locale.

(1.240 değerlendirme)(1.240 Bewertungen)
(1,240 مراجعة)

API

StarRating

PropTypeDefault
value
The rating; clamped to 0…max. The label keeps one decimal.
number—
max
Number of stars.
number5
step
Fill precision (half stars by default).
0.1 | 0.5 | 10.5
size
Star size and text size.
"sm" | "md" | "lg""md"
showValue
Average as text after the stars.
boolean—
count / countHref
“128 reviews”, as a link when countHref is set.
number / string—
label
Overrides “Rated {rating} out of {max}”.
string—
labels / locale / components
Strings, number format, Link adapter.
Partial<CommerceLabels> / string / BlockAdapters—

StarRatingInput

PropTypeDefault
name
Form field name (default: an auto id).
string—
value / defaultValue / onValueChange
Controlled or uncontrolled. 0 = no rating.
number / number / (v: number) => void—
allowHalf
Half-star steps: two radios per star.
boolean—
max
Number of stars.
number5
size
24 / 32 / 40px stars.
"sm" | "md" | "lg""md"
label / hideLabel / description
The legend (default “Rating”), visually hidden or not, and a hint under it.
ReactNode / boolean / ReactNode—
required / disabled / form / id
Native form attributes.
boolean / boolean / string / string—