Forms
Rating
Stars to rate something, or to show a rating.
Ant Design: Rate
import { Rating } from '@alea/ui';
Examples
Rating
Hover previews; arrows change it.
4 of 5
Read only and sizes
Showing a score.
Props
Rating props
Stars to rate something; arrows move, like radios (Ant's Rate).
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Extra class names for the root element. |
defaultValue | number | 0 | The rating to start with. |
getValueLabel | ((n: number) => string) | n | Words for each value, read by screen readers ("1 star" by default). |
isDisabled | boolean | - | Disables every part of it. |
isReadOnly | boolean | - | Shows the value without letting people change it. |
label | ReactNode | - | Name of the rating ("Rate this plugin"). |
max | number | 5 | Number of stars. Default 5. |
onChange | ((value: number) => void) | - | Called with the new rating. |
size | "sm" | "md" | "lg" | 'md' | sm, md (default) or lg. |
value | number | - | The rating (controlled), 0 for none. |
Accessibility
- A radio group: each star is "n stars"; read-only ratings are an image with the value.
Keyboard
| Key | Does |
|---|---|
| Arrow keys | Change the rating |
Do and don't
Do
- Show the count of ratings next to the stars.
- Use allowHalf only for display, not for input.
Don't
- Don't use stars for a yes/no question.
- Don't make it required without saying so.