Skip to content

Rating

Beta
Get Ritla UI

An average star rating with the score and the review count, read as one sentence: “Rated 4.8 out of 5”.

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

PreviewCode
EnglishMirroredArabic
LTR →

Installation

  1. Add the component

    npx ritla add rating

    Also works with shadcn: npx shadcn@latest add @ritla/rating

  2. Or copy by hand

    Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.

Usage

rating.tsx
import { Rating } from "@/components/ui/rating";<Rating value={4.8} count={126} />

API reference

Rating

PropTypeDefaultDescription
valuenumberNoneThe average, 0 to max. Stars round to the nearest star; the score shows one decimal.
maxnumber5The number of stars.
countnumberNoneThe number of reviews, in brackets.
showScore / showCountbooleantrueFigma's Show score and Show count.
labelstringNoneThe accessible name. Default “Rated 4.8 out of 5, 126 reviews” in the page language.

Accessibility

ARIA

  • The whole rating is one image (role="img") with its name, so screen readers never read the stars one by one.
  • Filled stars are icon/warning/dim and empty ones icon/gray/faint: the difference is in the fill as well, never color alone.

Arabic and RTL notes

Mirrors

  • The stars fill from the right, with the score and count after them on the left, because the row follows the page direction.

Does not mirror

  • The star shape itself never mirrors.
Numerals
The score and count use the page numerals: 4.8, or ٤٫٨ with numerals on RitlaProvider.
Arabic typography
label-14 Semibold for the score, label-14 in gray/muted for the count.