Reference
Rating
Stars, as radio buttons a screen reader hears as a choice of one to max:: the arrow keys move between them; .half takes halves; .readonly only shows.
Rating(bind: State, max: Number, label: String, …)
Since 6.2.0
max
label
half
readonly
You gave it 4 of 5
Example
state stars = 4
Rating(bind: stars, max: 5, label: "Your rating")
Text("You gave it {stars} of 5").muted
Half stars
state score = 3.5
Rating(bind: score, max: 5, label: "Score").half
Read-only: an average shown, not asked
state average = 4
Rating(bind: average, max: 5, label: "Average rating").readonly
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
bind: | State (required) | — | The |
max: | Number | 5 | How many stars it draws, and the highest rating |
label: | String (required) | — | What is being rated: the group's name, read once; with |
half: | Bool | false | Half stars too: the rating moves in steps of 0.5 rather than 1. Written as a flag, |
readonly: | Bool | false | Shown, not chosen: drawn as an image ( |
Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.
Flags and cases
A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.
.half
.readonly
Events
Every element also takes the props, the events and the attribute families listed on every element.
Slots
It takes no slots.
Renders with the class wf-rating, stable across releases, so a stylesheet may target it.