Skip to content

StarRating

SVG-based star rating with half-star support and customizable colors / size.

Basic Usage

vue
<template>
  <MStarRating :model-value="3.5" />
</template>

Interactive

Click the left half of a star for .5, right half for a full star.

Score: 0
vue
<script setup>
import { ref } from 'vue'
const score = ref(0)
</script>

<template>
  <MStarRating v-model="score" :readonly="false" :size="28" />
</template>

Custom Style

Props

NameTypeDefaultDescription
modelValuenumber-Current score (0.5 step)
maxStarsnumber5Total stars
sizenumber20Star size (px)
gapnumber2Gap between stars (px)
fillColorstring'#FBBF24'Filled color
emptyColorstring'#D1D5DB'Empty color
strokeWidthnumber1.5Stroke width
readonlybooleantrueRead-only
wrapperClassstring''Wrapper class

Events

NameArgsDescription
update:modelValue(value: number)Emitted when score changes

Released under the MIT License.