Skip to content

Early previewhamur is not on npm yet. The components are being built in the open, follow along on GitHub.

UIComponentsReact

Rating Display

Stars that show a score that cannot be changed, such as an average of reviews.

Built on the headless Rating Display.See its API in Docs

Rendered by React 19.3.1

rating-display.tsx

Installation

npx shadcn@4.23.0 add https://hamur.dev/r/react/rating-display.json

It also adds utils. The app needs its setup first: Installation.

Usage

Pass value (any number, clamped to 0 to max) and write one RatingDisplayItem per star, with index from 1 to max. Each star fills as far as the value reaches through --rating-item-fill, so 4.3 fills a third of the fifth star. The stars are one image, named "Rated 4.3 out of 5", from the headless Rating Display.

import { RatingDisplay, RatingDisplayItem } from '@/components/ui/rating-display'

Examples

Default

An average of 4.3 out of five.

Its preview and code are at the top of the page.

shadcn/ui has no Rating Display, so this item takes Base UI's component ID as its slug and one name per Base UI part. It is Rating's star at icon size; use Rating where the reader picks a score.

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 Display's API reference.