Forms
Rating
A star rating. By default you set it with arrow keys; readOnly turns it into a display.
ReactVueWeb Components
View in Storybook Playground
Examples
<Rating defaultValue={3} label="評価" onChange={setScore} />
<Rating value={4} readOnly /> Props
| Name | Type | Default | Description |
|---|---|---|---|
value | number | — | Controlled value (0–`max`). |
defaultValue | number | 0 | Initial value when uncontrolled. @default 0 |
onChange | (value: number) => void | — | Called with the newly selected rating. |
max | number | 5 | Number of stars. @default 5 |
name | string | — | Radio-group name (auto-generated if omitted). |
size | 'sm' | 'md' | 'lg' | md | Control size. @default 'md' |
readOnly | boolean | false | Render as a non-interactive, labeled display. @default false |
disabled | boolean | false | Disable interaction. @default false |
label | string | Rating | Group label, e.g. "Rating". @default 'Rating' |
starLabel | (n: number, max: number) => string | ${n} / ${max} | Builds each star's accessible name. @default `${n} / ${max}` |
Accessibility
- Body/background contrast is ≥ 7:1 (AAA) in both light and dark.
- Every interaction works with the keyboard alone.
- The focus ring is always visible.
- Respects prefers-reduced-motion and stops excessive motion.
Every component is designed to meet WCAG 2.1 AAA.