UIComponentsReact
A row of stars to pick a score, with half stars and a button to clear it.
Built on the headless Rating.See its API in Docs
Rendered by React 19.3.1
Installation
npx shadcn@4.23.0 add https://hamur.dev/r/react/rating.jsonIt also adds utils. The app needs its setup first: Installation.
Usage
Write one RatingItem per star, with value from 1 to max; each draws a star whose filled part follows --rating-item-fill, so a fractional step shows half stars, and a hover previews the score. Name the group with aria-label or a Field label. RatingClear (with allowClear a press on the checked star clears too) and RatingValue go inside Rating. The radio group, its keys, the star names and the form value come from the headless Rating.
import {
Rating,
RatingClear,
RatingItem,
RatingValue,
} from '@/components/ui/rating'Examples
Default
Five stars with half steps, the value and a clear button.
shadcn/ui has no Rating, so this item takes Base UI's component ID as its slug and one name per Base UI part. Its stars are lucide's Star in primary over a muted outline, 24px targets with the radio's focus ring; Clear is a ghost icon button. Rating Display shows an average with the same stars.
API reference
The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Rating's API reference.