SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

Rating

A score out of a few stars, read at a glance.

(128)42 reviews
View code
tsx
<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.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Or copy it into your project to edit it:

Terminal
sdxc ui add rating

Usage

typescript
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

tsx
<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.

PropTypeRequiredDescription
valuenumberYesThe score, fractional, between 0 and max; a value outside is held to the scale.
countnumberNoHow many ratings the score averages, shown after the stars as "(128)".
maxnumberNo
size"sm" | "md"No
labelstringNoWhat assistive tech reads; {value} and {max} fill in. @default "{value} out of {max} stars"
countLabelRemixNodeNoReplaces the "(128)" text, such as "128 reviews" or a link to them.

Also accepts everything in Omit<TagProps<"span">, "children">.

@sdxc/ui

Can’t find it? Contact us