Skip to content

Rating

A star rating input, built on Reka UI's Rating primitive.

Usage

v-model is a plain number between 0 and length (5 by default):

vue
<script setup lang="ts">
const value = ref(3)
</script>

<template>
  <SRating v-model="value" aria-label="Rate your experience" />
</template>

Half-star precision

step sets how fine-grained a single star's own value can be - one of 1 (default), 0.5, 0.25, or 0.1. 0.5 splits each star into a left (half) and right (whole) half, each its own clickable region:

vue-html
<SRating v-model="value" :step="0.5" />

Clearable

Clicking the currently-selected star again resets the value to 0:

4 out of 5 - click the current star again to clear

vue-html
<SRating v-model="value" clearable />

Sizes

vue-html
<SRating :default-value="4" size="lg" />

Color

vue-html
<SRating :default-value="4" color="success" />

Read-only display

disabled blocks interaction entirely - paired with a fractional model-value/step, this is the same component used purely to display a rating (an average review score, for one), not just collect one:

vue-html
<SRating :model-value="4.5" :step="0.5" disabled aria-label="4.5 out of 5" />

Vertical

vue-html
<SRating v-model="value" orientation="vertical" />

Forms integration

Wrap it in FormField to get id/name/invalid and aria-describedby wired up automatically - invalid falls back to FormField's own state when not set directly on the rating, and size does the same.

Custom :ui

To see exactly what you'd be overriding - the current default classes for every slot and variant - here's Rating's own theme file:

Theme source "rating" not found

Props

PropTypeDefault
idstring-
modelValuenumber-
defaultValuenumber-
lengthnumber5
step1 | 0.5 | 0.25 | 0.11
clearablebooleanfalse
hoverablebooleantrue
disabledbooleanfalse
invalidbooleanfalse
orientation'horizontal' | 'vertical'horizontal
size'sm' | 'md' | 'lg'md
color'primary' | 'neutral' | 'secondary' | 'success' | 'danger' | 'info' | 'warning'primary
namestring-
requiredbooleanfalse
uiPartial<Record<RatingSlot, string | object>>-

Events

EventPayloadDescription
update:modelValuenumberFires when a star (or half-star) is clicked
Edit this page