Forms Form-associated
Rating <pm-rating>
Star rating. Radio-group keyboard behaviour; form-associated; readonly for display.
Sizes
Set with the size attribute; controls keep touch-sized targets on phones.
size="sm"size="md"size="lg"Tones
Set tone on the element, or data-tone on any ancestor to tone a whole area.
tone="accent"tone="secondary"tone="neutral"tone="success"tone="warning"tone="danger"tone="info"States
Each state is one attribute.
DisabledRead-onlyRequiredErrorWith a hintAttributes
| Attribute | Type | Default | Description |
|---|---|---|---|
value | number | 0 | Number of stars chosen (0 = none). |
max | number | 5 | Number of stars shown. |
name | string | — | Form field name: the value is submitted under it. |
label | string | Rating | Accessible name of the stars (not shown on screen). |
size | 'sm' | 'md' | 'lg' | — | Star size. |
readonly | boolean | false | Show the rating as a picture (not a control); the value is still submitted. |
disabled | boolean | false | Not interactive and not submitted. |
clearable | boolean | false | Choosing the current value again clears it. |
hint | string | — | Help text under the field, linked to it for screen readers. |
error | string | — | Custom error message. Setting it marks the field invalid. |
required | boolean | false | The form cannot be submitted until a value is chosen. |
Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.
Events
| Event | React / Svelte prop | Description |
|---|---|---|
pm-change | onPmChange | Value changed. |
Methods
checkValidity(), reportValidity(), validate()