Rating
Pick a score out of five stars, in whole or half stars. The fill wipes along the row from the old score to the new one.
Examples
Default
Point at the stars to preview a score, and click to pick it. In a <form>, name sends the score; invalid colours the stars until one is picked.
Half stars
Set step={0.5}: the first half of a star picks the half. The arrow keys move by a half.
Read only
Set readOnly to show a score, such as an average: any fraction is drawn, and a screen reader reads it as one image.
Max
Set max for another number of stars. In a narrow column the stars share its width.
Your score for the March release
Scores close a week after a release.
Disabled
A disabled rating fades and can’t be changed. Say why beside it.
Installation
npx shadcn@latest add https://kinoui.com/r/rating.json- Files
lib/reduce-motion.tslib/resize.tslib/choice.tslib/controllable.tscomponents/kino/rating.tsx- Packages
@base-ui/react- Global CSS
- the feels, the density tokens, the shape tokens and the success and warning colours
New to Kino? Installation covers what your project needs first and the @kino namespace.
API reference
Props
Data attributes
CSS variables
Accessibility
- It follows the radio group pattern: Tab moves into the row at the picked score, and the arrow keys move the pick, by a half with
step={0.5}. - Name it with
aria-label, or witharia-labelledbypointing at its question. Each score is named "3.5 out of 5 stars"; passgetAriaLabelto word it another way. - A pointer aims at a whole star, at least 24px, and with half steps its first half picks the half, as a slider’s track does.
- A picked star is filled and an empty one is an outline, so the score never relies on colour. In forced colours the filled stars take the system highlight.
- Read only, it is one image named with its score, such as "4.3 out of 5 stars".
- When the system asks for less motion, the fill moves at once and a held star doesn’t shrink.