A star rating, for input or display.
A port of the Pines rating.
<.rating value={4} />
<.rating name="score" value={3} interactive />
Summary
Forms
Renders a star rating.
Forms
Renders a star rating.
Examples
<.rating value={4} />
<.rating name="score" value={@score} interactive phx-change="rate" />Accessibility
A read-only rating is a single img-role element with a text alternative
("4 out of 5 stars"), so a screen reader announces the rating once rather than reading five
separate stars.
An interactive rating is a radiogroup of real radio inputs — keyboard-navigable with
arrow keys for free, and submits without JavaScript. Alpine only drives the hover preview.
Attributes
id(:string) - Defaults tonil.value(:integer) - Defaults to0.max(:integer) - Defaults to5.name(:string) - Emits a hidden input so the rating submits with a form. Defaults tonil.interactive(:boolean) - Allows the user to set the rating. Read-only display otherwise. Defaults tofalse.size(:string) - Defaults to"md". Must be one of"sm","md", or"lg".label(:string) - Defaults tonil.show_value(:boolean) - Defaults tofalse.class(:string) - Defaults tonil.- Global attributes are accepted.