Forms
Rating
A row of stars for rating something, or for showing an already-rated value. Editable by default; add `readonly` to only display it.
Installation #
With the Nuxt module, every component is auto-imported — there is nothing to add. In a plain Vue project, import what you use:
Copy
import { JRating } from '@juxtui/ui'Usage #
Copy
<JRating v-model="rating" label="Rate this product" />Set readonly to show a static value, e.g. an average — pair it with allow-half for half-star precision. Editing is always whole stars.
Variants & examples #
Read-only average#
allow-half only takes effect in readonly mode.
3.5 out of 5
Sizes#
API #
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| modelValue | number | 0 | Bound with v-model. |
| max | number | 5 | Number of stars. |
| readonly | boolean | false | Static display mode — no interaction, ideal for showing an average. |
| disabled | boolean | false | Disables editing. |
| size | 'sm' | 'md' | 'lg' | 'md' | Star size. |
| label | string | — | Accessible name for the group, e.g. “Rate this product”. Defaults to a description of the current value in readonly mode. |
| allowHalf | boolean | false | Allow half-star precision. Only applies in readonly mode. |
Events
| Event | Payload | Description |
|---|---|---|
| update:modelValue | number | Emitted when a star is chosen. |
Accessibility #
- Editable mode is
role="radiogroup"with onerole="radio"star per value, exposingaria-checkedand a rovingtabindexso only one star sits in the tab order. - Read-only mode instead renders
role="img", labelled with a summary of the value, e.g. “4 out of 5 stars”. - Fill is drawn by width on an inner element, not colour alone, and the accessible name always carries the number.
Keyboard #
| Key | Action |
|---|---|
| →↑ | Increases the rating by one star. |
| ←↓ | Decreases the rating by one star. |
| Home | Clears the rating to zero. |
| End | Sets the rating to `max`. |