Rating component is a star based selection input.

import Rating from 'primevue/rating';

Two-way value binding is defined using v-model.

<Rating v-model="value" />

A cancel icon is displayed to reset the value by default, set cancel as false to remove this option.

<Rating v-model="value" :cancel="false" />

Number of stars to display is defined with stars property.

<Rating v-model="value" :stars="10" />

Custom icons are used to override the default icons with onicon, officon and cancelicon slots.

<Rating v-model="value">
    <template #cancelicon>
        <img src="/images/rating/cancel.png" height="24" width="24" />
    <template #onicon>
        <img src="/images/rating/custom-onicon.png" height="24" width="24" />
    <template #officon>
        <img src="/images/rating/custom-officon.png" height="24" width="24" />

When readOnly present, value cannot be edited.

<Rating v-model="value" readonly :cancel="false" />

When disabled is present, a visual hint is applied to indicate that the Knob cannot be interacted with.

<Rating v-model="value" disabled />

Screen Reader

Rating component internally uses radio buttons that are only visible to screen readers. The value to read for item is retrieved from the locale API via star and stars of the aria property.

Keyboard Support

Keyboard interaction is derived from the native browser handling of radio buttons in a group.

tabMoves focus to the star representing the value, if there is none then first star receives the focus.
left arrowup arrowMoves focus to the previous star, if there is none then last radio button receives the focus.
right arrowdown arrowMoves focus to the next star, if there is none then first star receives the focus.
spaceIf the focused star does not represent the value, changes the value to the star value.