Rating
Express a rating with a familiar, keyboard-operable star control.
Preview
Change the example value; the preview reports the current state.
How was your experience?
Choose a rating from one to five stars.
Example
<.rating name="score" value={4} />
API contract
rating/1
uses declared Phoenix attributes and slots. This table is generated from the compiled component metadata.
| Attribute | Type | Required | Default | Accepted values |
|---|---|---|---|---|
name |
:string |
Yes | — |
Any value matching the declared type |
value |
:any |
No | nil |
Any value matching the declared type |
max |
:integer |
No | 5 |
Any value matching the declared type |
label |
:string |
No | "Rating" |
Any value matching the declared type |
readonly |
:boolean |
No | false |
Any value matching the declared type |
clearable |
:boolean |
No | false |
Any value matching the declared type |
half |
:boolean |
No | false |
Any value matching the declared type |
size |
:atom |
No | nil |
[nil, :xs, :sm, :md, :lg, :xl] |
class |
:any |
No | nil |
Any value matching the declared type |
rest |
:global |
No | — |
Any value matching the declared type |
States and behavior
Default and caller-supplied variants preserve semantic daisyUI colors and additive classes.
Keyboard and accessibility
Behavioral tests
These automated checks are applied to this component by the package and documentation test suites.
-
ExUnit
Rating selection
Renders one native radio per rating value, the selected value, size modifier, and optional clear control.
test/vaylan_ui/catalog_test.exs -
Browser
Rendered interaction
Selects rating value five and verifies the corresponding native radio becomes checked.
examples/docs/assets/test/browser-smoke.mjs -
Docs
Preview behavior contract
Classified as input. Change the example value; the preview reports the current state.
examples/docs/test/vaylan_ui_docs_web/controllers/page_controller_test.exs -
Docs
Stable public component page
Renders the component name, example, API contract, accepted values, and keyboard and accessibility guidance at its stable URL.
examples/docs/test/vaylan_ui_docs_web/controllers/page_controller_test.exs