Rating
Display visual rating indicators with optional interactivity and customizable color and size options.
Component
Props
| Props | Default | Type |
|---|---|---|
modelValue | 0 | number |
size | RatingItemSize.SM | RatingItemSize |
color | RatingItemColor.GOLD | RatingItemColor |
emptyIndicatorIcon | 'mdi:star-outline' | string |
halfIndicatorIcon | 'mdi:star-half-full' | string |
fullIndicatorIcon | 'mdi:star' | string |
isInteractive | false | boolean |
hoverPreview | true | boolean |
Usage
modelValue
Sets the value of the rating. Must be between 0 and 5. Supports v-model when isInteractive is enabled.
<template>
<Rating :modelValue="4" />
</template>
size
Sets the size of the rating. Uses the RatingItemSize enum.
<template>
<Rating :size="RatingItemSize.LG" />
</template>
Options
| Value | Description |
|---|---|
SM | sm |
MD | md |
LG | lg |
XL | xl |
XXL | xxl |
color
Sets the color of the rating. Uses the RatingItemColor enum.
<template>
<Rating :color="RatingItemColor.PRIMARY_BRAND" />
</template>
Options
| Value | Description |
|---|---|
GOLD | Stars with gold color |
PRIMARY_BRAND | Stars with primary brand color |
emptyIndicatorIcon
Sets the icon of the empty rating indicator.
<template>
<Rating emptyIndicatorIcon="mdi:star-outline" />
</template>
halfIndicatorIcon
Sets the icon of the half rating indicator.
<template>
<Rating halfIndicatorIcon="mdi:star-half-full" />
</template>
fullIndicatorIcon
Sets the icon of the full rating indicator.
<template>
<Rating fullIndicatorIcon="mdi:star" />
</template>
isInteractive
When set to true, the rating becomes interactive: items show a hand cursor, clicking sets the value (clicking the current value resets it to 0), and v-model updates are emitted.
<template>
<Rating v-model="rating" isInteractive />
</template>
hoverPreview
When isInteractive is enabled, sets whether the rating should show a preview when hovered.
<template>
<Rating v-model="rating" isInteractive hoverPreview />
</template>
RatingItem
The <RatingItem /> component is used to render a single rating indicator. It is used by the <Rating /> component.
Props
| Props | Default | Type |
|---|---|---|
icon | 'mdi:star-outline' | string |
size | RatingItemSize.SM | RatingItemSize |
color | RatingItemColor.GOLD | RatingItemColor |
isInteractive | false | boolean |
icon
Sets the icon of the rating indicator.
<template>
<RatingItem icon="mdi:star-outline" />
</template>
size and color
The use of size and color props is exactly the same as in the Rating component props.
<template>
<RatingItem
:color="RatingItemColor.GOLD"
:size="RatingItemSize.SM"
/>
</template>
isInteractive
Sets the interactive state of the rating indicator. If set to true, the rating indicator will display a hand cursor when hovered.