Rating
- (2,140)Full marks
- (128)4.3, shown as 4½
- (36)Half star
- (0)Not rated yet
A read-only star rating, with an optional number and review count, announced as one phrase such as "Rated 4.3 out of 5, 128 reviews".
A Markdown brief for Claude, Cursor or v0: install, setup, props and a complete example.
For how people rated something, such as a product, a place or an app. Add the review count, so the stars carry their weight.
Asking people for a rating? Choice, with 1 to 5 as its options. A score that isn’t out of stars? Metric.
One image, named like "Rated 4.3 out of 5, 128 reviews"; the stars themselves are hidden. Stars fill to the nearest half, and the name keeps the exact value.
import { Rating } from '@idyeah/diya'Stable since 1.0.0
valueRequirednumberThe rating, from 0 to max. Values outside that range are clamped, and one that isn't a number shows as 0. The stars fill to the nearest half (4.3 shows four and a half); the number and the accessible name keep one decimal.
countnumberHow many reviews the rating comes from, shown after the stars as '(128)' and announced as '128 reviews'. Leave it out to show the stars alone.
maxnumberHow many stars: a whole number from 1 to 10. Defaults to 5.
Default 5
showValuebooleanShows the value as a number before the stars, such as '4.3'. Defaults to false.
Default false
size"small" | "medium" | "large"Star and text size. Defaults to 'medium'.
Default 'medium'
Also takes every native <span> attribute, such as id, aria-* or data-*.