Dot Rating
Stars light up to the rating, and a part-filled one (an average of 4.3, say) is lit to exactly its share, its edge a dithered stipple. Hovering previews a rating, halves too if you allow them, and picking one throws a small burst of dots off the star. It's a slider to screen readers and the keyboard: arrows, Home and End, or a number key for that many stars. Read-only, it shows an average.
Needs: None. Canvas 2D.
Customize
step
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | – | The rating. Leave unset to let it keep its own. |
| defaultValue | number | 0 | The rating at first, when value isn't set. |
| onChange | (value: number) => void | – | Called with the new rating when one is picked. |
| max | number | 5 | How many stars. |
| step | 0.5 | 1 | 1 | Whole stars, or halves too. |
| readOnly | boolean | false | Show a rating, like an average, without taking one. |
| tone | string | "#f2a531" | The colour of a lit star. |
| pitch | number | 4 | Size of one dot in px. A star is 9 dots wide. |
| label | string | "Rating" | What's being rated, for screen readers. |
| className | string | – | Class on the rating. |
| style | CSSProperties | – | Style on the rating. |