Rating
A star (or custom icon) rating input or display.
Playground
<Rating
value={3}
max={5}
onChange={setValue}
/>
Custom icon
import { StarIcon } from '@88khp/vajra-icons';
<Rating value={4} icon={StarIcon} onChange={setValue} />
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | Required. Current rating. | |
onChange | (value: number) => void | Called with the pressed cell's value. Omit (or set isReadOnly) for a display-only rating. | |
max | number | 5 | Number of icon cells. |
isReadOnly | boolean | false | Display-only; taps are ignored. |
isDisabled | boolean | false | Dims opacity and ignores taps. |
size | number | 24 | Icon size in px. |
color | TVajraColors | 'warning' | Filled-cell color. |
emptyColor | TVajraColors | 'border' | Empty-cell color. |
icon | TVajraIconComponent | Filled-cell icon. Defaults to a plain ★ glyph. | |
emptyIcon | TVajraIconComponent | Empty-cell icon. Defaults to a plain ☆ glyph. |