Rating
A score out of a few stars, read at a glance.
(128)42 reviews
View code
<Rating value={4.6} count={128} />
<Rating value={3.5} size="sm" countLabel="42 reviews" />
<Rating value={8.4} max={10} label="{value} out of {max}" />Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Or copy it into your project to edit it:
sdxc ui add ratingUsage
import { Rating } from "@sdxc/ui";Renders the stars as one role="img" whose name states the score, followed by the count.
Stars take --ui-rating-color (the warning tone by default) and empty ones the border tone,
so a theme recolours every rating at once.
Examples
<Rating value={5} size="sm" label="Rated {value} of {max}" />Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Required | Description |
|---|---|---|---|
value | number | Yes | The score, fractional, between 0 and max; a value outside is held to the scale. |
count | number | No | How many ratings the score averages, shown after the stars as "(128)". |
max | number | No | |
size | "sm" | "md" | No | |
label | string | No | What assistive tech reads; {value} and {max} fill in. @default "{value} out of {max} stars" |
countLabel | RemixNode | No | Replaces the "(128)" text, such as "128 reviews" or a link to them. |
Also accepts everything in Omit<TagProps<"span">, "children">.