Form
Rating
Stars to rate with, in whole steps or in halves and quarters, cleared by choosing the same star again.
WAI-ARIA tested
Import
main.ts
import { Rating } from '@vitral/vue';Basic
Your ratingValue: 3
Half stars
A step of 0.5. Press the left half of a star for the half, the right half for the whole; the arrows move by the step.
How was it?Value: 3.5
Quarters
Any step divides the star: the filled one is drawn over the empty one and clipped to the fraction, so there is no half-drawn glyph to keep.
PrecisionValue: 4.25
An average, read-only
What a rating is most often for: a number that is not a whole star and was never chosen by this reader.
4.3 out of 5, from 1,284 reviews
More stars, other icons
Read-only and disabled
API
Read from packages/vue/src/components/Rating/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| stars | number | How many stars. Defaults to 5. |
| step | number | The smallest change: `1` whole stars, `0.5` halves, `0.25` quarters. A whole-star rating is a radio group of stars, which is what it is; a fractional one is a slider, because half a star is not an option in a list, it is a position on a scale. |
| clearable | boolean | A press on the chosen star clears the rating, and the arrow keys can reach zero. Defaults to true. |
| readonly | boolean | — |
| disabled | boolean | — |
| invalid | boolean | — |
| onIcon | IconProp | The icon of a chosen star. Defaults to a filled star. |
| offIcon | IconProp | The icon of a star not chosen. Defaults to an outlined star. |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| change | event: { originalEvent: Event; value: number | null } | — |
| focus | event: FocusEvent | — |
| blur | event: FocusEvent | — |
Slots
| Name | Slot props | Description |
|---|---|---|
| onicon | (props: { value: number }) | — |
| officon | (props: { value: number }) | — |