Fine-tune light, shadows, borders, neumorphic
Light and shadows
Borders
Neumorphic
Forms Form-associated

Rating <pm-rating>

Star rating. Radio-group keyboard behaviour; form-associated; readonly for display.

Full screen

Props

<script type="module"> import '@prismora/css'; import '@prismora/elements/rating'; </script> <pm-rating label="Rate your stay" value="4"></pm-rating>

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.

Disabled
Read-only
Required
Error
With a hint

Attributes

AttributeTypeDefaultDescription
valuenumber0Number of stars chosen (0 = none).
maxnumber5Number of stars shown.
namestring—Form field name: the value is submitted under it.
labelstringRatingAccessible name of the stars (not shown on screen).
size'sm' | 'md' | 'lg'—Star size.
readonlybooleanfalseShow the rating as a picture (not a control); the value is still submitted.
disabledbooleanfalseNot interactive and not submitted.
clearablebooleanfalseChoosing the current value again clears it.
hintstring—Help text under the field, linked to it for screen readers.
errorstring—Custom error message. Setting it marks the field invalid.
requiredbooleanfalseThe 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

EventReact / Svelte propDescription
pm-changeonPmChangeValue changed.

Methods

checkValidity(), reportValidity(), validate()

Used in templates

Product pageLanding pageFeedback survey