Skip to main content
Version: latest
Works everywhere

Rating works in both server and client environments. Always use the standard import (e.g. @prokodo/ui/rating) — the library detects the runtime automatically.

Rating

Rating renders a star-based rating input. Supports interactive selection, read-only display, half-star precision, and accessible ARIA role slider.

Live demo →

Overview

import { Rating } from "@prokodo/ui/rating"
;<Rating name="product-rating" value={rating} onChange={setRating} max={5} />

Import

import { Rating } from "@prokodo/ui/rating"

CSS:

import "@prokodo/ui/rating.css"

Props

PropTypeDefaultRequiredDescription
idstringHTML id for accessibility linking.
labelstringAccessible label text for the rating group.
labelPropsLabelPropsProps forwarded to the label element.
valuenumberControlled rating value.
defaultValuenumberUncontrolled initial rating value.
minnumber1Minimum rating value.
maxnumber5Maximum rating value (number of stars).
disabledbooleanfalseDisable rating interaction.
requiredbooleanfalseMark field as required.
fullWidthbooleanfalseStretch to container width.
colorVariantsAccent color variant.
helperTextstringHelper text shown below.
errorTextstringError message.
onChange(value: number) => voidCalled when rating changes.
classNamestringCSS class on root element.

See src/components/rating/Rating.model.ts for the full RatingProps type.


Design Tokens

Customise Rating via CSS custom properties on :root or a scoped ancestor.

TokenDefaultDescription
--pk-rating-icon-size1.5remStar icon size
--pk-rating-gapvar(--pk-space-lg)Gap between star icons
--pk-rating-icon-fgvar(--pk-palette-grey-200)Unfilled star colour
--pk-rating-icon-fg-filledvar(--pk-color-brand)Filled / hovered star colour
--pk-rating-icon-fg-disabledvar(--pk-palette-grey-200)Disabled star colour
--pk-rating-focus-ringvar(--pk-color-brand)Keyboard focus ring colour
--pk-rating-helper-fgvar(--pk-palette-grey-300)Helper text colour
--pk-rating-error-fgvar(--pk-color-error)Error text colour

AIC Note

Use the standard import path in application code:

import { Rating } from "@prokodo/ui/rating"

No separate /client or /lazy import selection is required in consumer code.

AIC components also support a priority flag for critical above-the-fold elements. This is most visible on Image (native preloading via <link rel="preload"> for above-the-fold content).


WCAG 2.2 Status

CriterionNameStatusNote
1.3.1Info and Relationships (A)✅ FulfilledSemantic structure (headings, lists, labels, landmarks) must be conveyed programmatically via HTML or ARIA.
1.4.1Use of Color (A)🔍 Manual reviewColor must not be the only means of conveying information (e.g. error states, required field markers).
2.1.1Keyboard (A)🔍 Manual reviewAll functionality must be operable via keyboard alone, without requiring specific timing.
2.4.7Focus Visible (AA)🔍 Manual reviewA visible keyboard focus indicator must be present on every interactive element. Verify against the applied product theme.
2.5.3Label in Name (A)✅ FulfilledFor components with a visible label, the accessible name must contain or match the visible label text.
3.3.2Labels or Instructions (A)✅ FulfilledEvery form input requires a programmatically associated label or a visible instruction.
4.1.2Name, Role, Value (A)✅ FulfilledName, role, and state of all interactive UI components must be programmatically determinable via native HTML semantics or ARIA.

Test coverage: 3 jest-axe assertion(s) across 5 test file(s) · 8 ARIA attribute occurrence(s) in source scan. Criteria marked 🔍 require manual verification in the final product integration and theme context.

Storybook

👉 Open Rating in Storybook


Source

src/components/rating/Rating.model.ts