Skip to main content
You are viewing Pre-Alpha documentation.
Vuetify0 LogoVuetify0 Logo
Theme
Mode
Palettes
Accessibility
Vuetify One
Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

Rating

A headless rating component for building star/icon rating inputs with hover preview, keyboard navigation, and half-step support. Uses createRating internally for value management.


Renders elementIntermediateApr 3, 2026

Usage

Rating supports whole and half-star modes. Items expose their state via data attributes for CSS-only styling.

Rating: 0

<script setup lang="ts">
  import { Rating } from '@vuetify/v0'
  import { shallowRef } from 'vue'

  const rating = shallowRef(0)
</script>

<template>
  <div class="flex flex-col items-center gap-4">
    <Rating.Root v-slot="{ attrs }" v-model="rating" class="flex gap-1 focus:outline-none">
      <div v-bind="attrs" class="flex gap-0.5">
        <Rating.Item
          v-for="i in 5"
          :key="i"
          as="button"
          class="size-8 text-xl cursor-pointer focus:outline-none [&[data-state=full]]:text-amber-500 [&[data-state=empty]]:text-on-surface-variant/40"
          :index="i"
        >
          <template #default="{ state }">
            {{ state === 'full' ? '★' : '☆' }}
          </template>
        </Rating.Item>
      </div>
    </Rating.Root>

    <p class="text-sm text-on-surface-variant">
      Rating: {{ rating }}
    </p>
  </div>
</template>

Anatomy

vue
<script setup lang="ts">
  import { Rating } from '@vuetify/v0'
</script>

<template>
  <Rating.Root>
    <Rating.Item />

    <Rating.HiddenInput />
  </Rating.Root>
</template>

Examples

Basic

Click a star to set the rating. Hover to preview. Keyboard: Arrow keys to adjust, Home for 0, End for max.

Rating: 0

Half Stars

Enable half prop for 0.5-step precision. Hover over the left or right half of a star to preview half values.

Rating: 2.5

Accessibility

Keyboard

KeyAction
ArrowRight / ArrowUpIncrement by step (1 or 0.5)
ArrowLeft / ArrowDownDecrement by step
HomeSet to 0
EndSet to size

ARIA

Rating.Root provides role="slider" with aria-valuenow, aria-valuemin, aria-valuemax, and aria-valuetext (e.g. “3 out of 5”). When disabled or readonly, the corresponding aria-disabled and aria-readonly attributes are set.

Data Attributes

Root:

AttributeDescription
data-disabledPresent when disabled
data-readonlyPresent when readonly
data-hoveringPresent during hover

Item:

AttributeValuesDescription
data-statefull | half | emptyFill state
data-highlightedpresent/absentWithin hover range
data-disabledpresent/absentInherited from root
data-readonlypresent/absentInherited from root

API Reference

The following API details are for all variations of the Rating component.

Rating.Root

Props

modelValue

number | undefined

Current rating

Default: 0

size

number | undefined

Total items (default: 5)

Default: 5

half

boolean | undefined

Enable 0.5 increments

Default: false

disabled

MaybeRefOrGetter<boolean> | undefined

Disable interaction

Default: false

readonly

MaybeRefOrGetter<boolean> | undefined

Show value, prevent changes

name

string | undefined

Form field name — triggers hidden input

namespace

string | undefined

Namespace for context provision

Default: "v0:rating:root"

Slots

default

RatingRootSlotProps

Rating.HiddenInput

Props

namespace

string | undefined

Namespace for context injection from parent Rating.Root

Default: "v0:rating:root"

Rating.Item

Props

index required

number

1-based position

namespace

string | undefined

Namespace for context injection from parent Rating.Root

Default: "v0:rating:root"

Slots

default

RatingItemSlotProps
Was this page helpful?

© 2016-1970 Vuetify, LLC
Ctrl+/