Rating
stableCollects a numeric star rating.
Basic usage
Examples
Read-only rating
Use readOnly to display an existing score without interaction.
Custom max and labels
Change max or label text for different scoring systems.
Sizes, colors and custom icons
Rating supports controlled/uncontrolled values, custom labels, max, sizes and colors.
Features
- Controlled or uncontrolled.
- Keyboard-focusable items.
Installation
bash
pnpm dlx structyl add ratingAPI Reference
Rating
Star rating input.
| Prop | Type | Default |
|---|---|---|
| value | defaultValue | numberControlled or uncontrolled rating value. | — |
| onValueChange | (value: number) => voidCalled when value changes. | — |
| max | numberNumber of rating items. | 5 |
| disabled | readOnly | booleanInteraction state. | false |
| name | stringHidden input name for forms. | — |
| size | 'small' | 'medium' | 'large'Star size. | 'medium' |
| color | 'default' | 'primary' | 'success' | 'warning' | 'destructive' | 'muted'Checked item color. | 'primary' |
| icon | emptyIcon | React.ReactNodeCustom checked and unchecked visuals. | — |
| getLabelText | (value: number) => stringAccessible label generator. | — |
| precision | numberDocumented precision marker for design parity. | — |
| className | stringAdditional Tailwind classes merged with the component defaults. | — |