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.
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
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
id | string | — | ✅ | HTML id for accessibility linking. |
label | string | — | — | Accessible label text for the rating group. |
labelProps | LabelProps | — | — | Props forwarded to the label element. |
value | number | — | — | Controlled rating value. |
defaultValue | number | — | — | Uncontrolled initial rating value. |
min | number | 1 | — | Minimum rating value. |
max | number | 5 | — | Maximum rating value (number of stars). |
disabled | boolean | false | — | Disable rating interaction. |
required | boolean | false | — | Mark field as required. |
fullWidth | boolean | false | — | Stretch to container width. |
color | Variants | — | — | Accent color variant. |
helperText | string | — | — | Helper text shown below. |
errorText | string | — | — | Error message. |
onChange | (value: number) => void | — | — | Called when rating changes. |
className | string | — | — | CSS class on root element. |
See
src/components/rating/Rating.model.tsfor the fullRatingPropstype.
Design Tokens
Customise Rating via CSS custom properties on :root or a scoped ancestor.
| Token | Default | Description |
|---|---|---|
--pk-rating-icon-size | 1.5rem | Star icon size |
--pk-rating-gap | var(--pk-space-lg) | Gap between star icons |
--pk-rating-icon-fg | var(--pk-palette-grey-200) | Unfilled star colour |
--pk-rating-icon-fg-filled | var(--pk-color-brand) | Filled / hovered star colour |
--pk-rating-icon-fg-disabled | var(--pk-palette-grey-200) | Disabled star colour |
--pk-rating-focus-ring | var(--pk-color-brand) | Keyboard focus ring colour |
--pk-rating-helper-fg | var(--pk-palette-grey-300) | Helper text colour |
--pk-rating-error-fg | var(--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
| Criterion | Name | Status | Note |
|---|---|---|---|
| 1.3.1 | Info and Relationships (A) | ✅ Fulfilled | Semantic structure (headings, lists, labels, landmarks) must be conveyed programmatically via HTML or ARIA. |
| 1.4.1 | Use of Color (A) | 🔍 Manual review | Color must not be the only means of conveying information (e.g. error states, required field markers). |
| 2.1.1 | Keyboard (A) | 🔍 Manual review | All functionality must be operable via keyboard alone, without requiring specific timing. |
| 2.4.7 | Focus Visible (AA) | 🔍 Manual review | A visible keyboard focus indicator must be present on every interactive element. Verify against the applied product theme. |
| 2.5.3 | Label in Name (A) | ✅ Fulfilled | For components with a visible label, the accessible name must contain or match the visible label text. |
| 3.3.2 | Labels or Instructions (A) | ✅ Fulfilled | Every form input requires a programmatically associated label or a visible instruction. |
| 4.1.2 | Name, Role, Value (A) | ✅ Fulfilled | Name, 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.