Rating

The VdRating component renders an interactive star-rating widget. Configure the maximum number of stars, pre-set a value, make it read-only, or pick a size variant — all through component props.

Basic 5-Star Rating
Pre-set Value (3 of 5)
3
Read-Only
4
Custom Max (10 Stars)
7
Size Variants

Small

4

Default

4

Large

4
API Reference

Usage

<script setup lang="ts">
import { ref } from "vue";
import { VdRating } from "@vanduo-oss/vd3";
const value = ref(3);
</script>

<template>
  <VdRating v-model="value" :max="5" @change="onChange" />
</template>

CSS Classes

ClassDescription
.vd-ratingContainer wrapping the star elements
.vd-rating-starIndividual star element (filled or empty depending on value)
.vd-rating-readonlyAdded to the container when readonly; disables hover/click interactions
.vd-rating-smSmall size variant — rendered when the size prop is "sm"
.vd-rating-lgLarge size variant — rendered when the size prop is "lg"
.vd-rating-valueOptional text element displaying the numeric value (e.g. "4 / 5")

Component API

Prop / eventDescription
v-model (modelValue)Two-way bound rating value (number).
:maxNumber of stars (default 5).
:size'sm' | 'lg' size variant.
:readonlyDisplay-only, non-interactive when true.
@update:modelValue / @changeFired with the new value when the user picks a star.
Accessibility
  • The container renders role="radiogroup" with aria-label="Rating".
  • Each star button has role="radio" with aria-checked, aria-label (e.g. "1 star", "3 stars"), and roving tabindex (0 on the active/first star, -1 on the rest).
  • ArrowRight / ArrowUp increment the rating and ArrowLeft / ArrowDown decrement it, moving DOM focus to the newly selected star.
  • When readonly is set, all star buttons receive tabindex="-1" and ignore pointer and keyboard changes.