Rating
A score out of a number of stars, chosen with a press or the arrow keys, or shown read-only.
Stability: experimental
Props
| Prop | Type | Default | Means |
|---|---|---|---|
label | string | What is rated; the group's accessible name. | |
value | number | bindable(0) | The score, from 1 to max; 0 for none yet. Bind it with bind:value={name}. |
max | number | 5 | How many stars. |
readonly | boolean | false | Shows the score without letting it change. |
States
| State | Looks like |
|---|---|
default | Stars up to the score are lit; the rest are the border colour. |
read-only | The same stars, never focused. |
Accessibility
| role | radiogroup (img when read-only) |
| name | The label prop; read-only, the label with the score. |
| focus | One Tab stop, on the chosen star (the first while there is none). |
| keyboard | The arrow keys move the score; Home and End go to the ends. |
Theme tokens
color.border color.primary radius.md space.1
Example
<Rating label="Your rating" bind:value={stars} />