Back to Blog

vue-star-rate: Zero-Dependency Vue 3.5+ Star Rating Component

VueTypeScriptOpen SourceAccessibilityComponentWCAGRatingnpm
Star rating component for Vue 3 with half-star support and full accessibility

Star ratings sound simple until you ship them to production. Then you need half-star precision, accessible keyboard navigation, RTL layouts, flexible icon sources, and correct ARIA semantics. I built vue-star-rate to handle all of that in a single zero-dependency Vue 3.5+ component.

Documentation & Live Demo

Installation

bash
pnpm add vue-js-star-rating

Requires Vue 3.5+. Uses defineModel and useTemplateRef — both stable in Vue 3.5. Zero runtime dependencies.

Basic Usage

vue
<script setup lang="ts"> import { ref } from 'vue'; import { VueStarRate } from 'vue-js-star-rating'; import 'vue-js-star-rating/dist/style.css'; const rating = ref(0); </script> <template> <VueStarRate v-model="rating" /> </template>

Half-Star Ratings

vue
<VueStarRate v-model="rating" :allow-half="true" :show-counter="true" />

The visual renderer fills exactly half of a star glyph. The emitted value is a decimal like 3.5.

Size Presets

vue
<VueStarRate v-model="rating" size="xs" /> <!-- 16px --> <VueStarRate v-model="rating" size="sm" /> <!-- 20px --> <VueStarRate v-model="rating" size="md" /> <!-- 24px — default --> <VueStarRate v-model="rating" size="lg" /> <!-- 32px --> <VueStarRate v-model="rating" size="xl" /> <!-- 40px --> <VueStarRate v-model="rating" :icon-size="28" /> <!-- Custom pixels -->

Custom Colors

vue
<VueStarRate v-model="rating" :colors="{ empty: '#27272a', filled: '#fbbf24', hover: '#fcd34d', half: '#fbbf24', }" />

Icon Providers

vue
<!-- Lucide (requires lucide-vue-next) --> <VueStarRate v-model="rating" icon-provider="lucide" /> <!-- FontAwesome (requires @fortawesome/fontawesome-free) --> <VueStarRate v-model="rating" icon-provider="fontawesome" /> <!-- Fully custom SVG via slot --> <VueStarRate v-model="rating" icon-provider="custom"> <template #icon="{ filled, size, color }"> <svg :width="size.width" :height="size.height" viewBox="0 0 24 24"> <circle cx="12" cy="12" r="10" :fill="filled ? color : 'none'" :stroke="color" stroke-width="2" /> </svg> </template> </VueStarRate>

Read-Only Mode

For review cards, dashboards, and product pages:

vue
<VueStarRate :model-value="4.5" :readonly="true" :allow-half="true" :show-counter="true" />

Keyboard Navigation

KeyAction
Arrow Right / UpIncrease rating
Arrow Left / DownDecrease rating
HomeSet to minimum
EndSet to maximum
1–9Jump to specific value
0Reset to minimum

The component uses role="group", aria-pressed on each star, and an aria-live counter — fully WCAG 2.2 compliant.

Tooltips and Counters

vue
<VueStarRate v-model="rating" :show-counter="true" counter-template="{value} / {max}" /> <VueStarRate v-model="rating" :show-tooltip="true" :tooltip-labels="['Terrible', 'Poor', 'Fair', 'Good', 'Excellent']" />

Full Configuration Example

vue
<VueStarRate v-model="rating" :max-stars="5" :allow-half="true" :show-counter="true" :show-tooltip="true" size="lg" :colors="{ empty: '#27272a', filled: '#fbbf24', hover: '#fcd34d', half: '#fbbf24' }" :animation="{ enabled: true, duration: 200, type: 'scale' }" :clearable="true" @change="(val, old) => console.log(val, old)" />

Props Reference

PropTypeDefaultDescription
v-modelnumber0Rating value
maxStarsnumber5Maximum stars
allowHalfbooleanfalseHalf-star precision
sizexs / sm / md / lg / xlmdSize preset
readonlybooleanfalseDisplay-only mode
clearablebooleanfalseClear button
showCounterbooleanfalseNumeric counter
showTooltipbooleanfalseHover tooltips
rtlbooleanfalseRight-to-left layout
iconProvidercustom / lucide / fontawesomecustomIcon source

Programmatic Control

typescript
const ratingRef = ref<InstanceType<typeof VueStarRate>>(); ratingRef.value?.reset(); ratingRef.value?.setRating(3.5); ratingRef.value?.getRating(); ratingRef.value?.focus();

Migration from v2

v2v3
lucideIcons propicon-provider="lucide"
role="slider"role="group" (WCAG 2.2)
animation: { scale: 1.15 }animation: { type: 'scale' }
Vue ^3.3.0 peer depVue ^3.5.0 peer dep

GitHub · npm · Full Documentation

pooya.blog

vue-star-rate: Zero-Dependency Vue 3.5+ Star Rating Component

Introducing vue-js-star-rating — a WCAG 2.2 accessible, TypeScript-first star rating component for Vue 3.5+. Half-star precision, multiple icon providers, full keyboard navigation, read-only mode, RTL support, and zero…

https://pooya.blog/blog/vue-star-rate

X / Twitter
Share
vue-star-rate: Zero-Dependency Vue 3.5+ Star Rating Component

Introducing vue-js-star-rating — a WCAG 2.2 accessible, TypeScript-first star rating component for Vue 3.5+. Half-star precision, multiple icon providers,…

https://pooya.blog/blog/vue-star-rate
LinkedIn
Share
vue-star-rate: Zero-Dependency Vue 3.5+ Star Rating Component

Introducing vue-js-star-rating — a WCAG 2.2 accessible, TypeScript-first star rating component for Vue 3.5+. Half-star precision, multiple icon providers, full keyboard navigation, read-only mode, RTL support, and zero runtime dependencies.

🔗 https://pooya.blog/blog/vue-star-rate
Facebook
Share
vue-star-rate: Zero-Dependency Vue 3.5+ Star Rating Component

Introducing vue-js-star-rating — a WCAG 2.2 accessible, TypeScript-first star rating component for Vue 3.5+. Half-star precision, multiple icon providers, full…

https://pooya.blog/blog/vue-star-rate
WhatsApp
Share
*vue-star-rate: Zero-Dependency Vue 3.5+ Star Rating Component*

_Introducing vue-js-star-rating — a WCAG 2.2 accessible, TypeScript-first star rating component for Vue 3.5+. Half-star precision, multiple icon providers, full…_

https://pooya.blog/blog/vue-star-rate
Telegram
Share
vue-star-rate: Zero-Dependency Vue 3.5+ Star Rating Component

Introducing vue-js-star-rating — a WCAG 2.2 accessible, TypeScript-first star rating component for Vue 3.5+. Half-star precision, multiple icon providers, full…

https://pooya.blog/blog/vue-star-rate

Common Questions

Answers to questions I hear most often from potential clients and collaborators.