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

createRating

Bounded number with discrete items. Give it a size, get items to iterate with full/half/empty state. Half-step support for 0.5 increments.


IntermediateApr 3, 2026

Usage

ts
import { createRating } from '@vuetify/v0'
import { shallowRef } from 'vue'

// Basic — standalone
const rating = createRating({ size: 5 })
rating.select(3)
rating.items.value
// [
//   { value: 1, state: 'full' },
//   { value: 2, state: 'full' },
//   { value: 3, state: 'full' },
//   { value: 4, state: 'empty' },
//   { value: 5, state: 'empty' },
// ]

// With half-step support
const half = createRating({ size: 5, half: true })
half.select(2.5)
half.items.value[2].state // 'half'

// With v-model (pass a ref)
const value = shallowRef(0)
const bound = createRating({ value, size: 5 })
bound.select(4)
value.value // 4

Reactivity

PropertyTypeReactiveDescription
valueWritableComputedRef<number>YesCurrent rating, clamped 0–size
sizenumberGetterTotal items
halfbooleanGetterHalf-step enabled
itemsComputedRef<RatingItem[]>YesItems with full/half/empty state
isFirstReadonly<Ref<boolean>>YesValue is 0
isLastReadonly<Ref<boolean>>YesValue equals size
select(v)(value: number) => voidSet rating
next()() => voidIncrement by step
prev()() => voidDecrement by step
first()() => voidSet to 0
last()() => voidSet to size

Examples

Basic

Standalone rating with navigation controls. Click a star or use the prev/next buttons.

0 / 5

API Reference

The following API details are for the createRating composable.

Functions

createRating

(_options?: RatingOptions) => R

Creates a rating instance.

createRatingContext

(_options?: RatingContextOptions) => ContextTrinity<R>

Creates a rating context for dependency injection.

useRating

(namespace?: string) => R

Returns the current rating instance from context.

Options

value

number | ShallowRef<number> | undefined

Initial value or ref for v-model.

Default: 0

size

MaybeRefOrGetter<number> | undefined

Total items.

Default: 5

half

MaybeRefOrGetter<boolean> | undefined

Enable 0.5 step increments.

Default: false

Properties

value

WritableComputedRef<number, number>

Current rating, clamped to 0–size

size

number

Total items

half

boolean

Whether half-steps are enabled

items

ComputedRef<RatingItemDescriptor[]>

Array of items with computed state

isFirst

Readonly<Ref<boolean, boolean>>

Whether value is at minimum (0)

isLast

Readonly<Ref<boolean, boolean>>

Whether value is at maximum (size)

Methods

select

(value: number) => void

Set rating to specific value

next

() => void

Increment by step (1 or 0.5)

prev

() => void

Decrement by step (1 or 0.5)

first

() => void

Set to 0

last

() => void

Set to size

Was this page helpful?

© 2016-1970 Vuetify, LLC
Ctrl+/