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

wf

state stars = 4 Rating(bind: stars, max: 5, label: "Your rating") Text("You gave it {stars} of 5").muted

Half stars

wf

state score = 3.5 Rating(bind: score, max: 5, label: "Score").half

Read-only: an average shown, not asked

wf

state average = 4 Rating(bind: average, max: 5, label: "Average rating").readonly

Props

Props of Rating
PropTypeUnsetMeaning

bind:

State (required)

—

The Number state it reads and writes: how many stars are chosen (halves with .half), 0 for none

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 .readonly it says Quality: 4 out of 5

half:

Bool

false

Half stars too: the rating moves in steps of 0.5 rather than 1. Written as a flag, .half, or half: true.

readonly:

Bool

false

Shown, not chosen: drawn as an image (role="img") that says the rating, with no stops for Tab. Written as a flag, .readonly, or readonly: true.

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.