Skip to content

API Reference

Props

PropTypeDefaultDescription
modelValuenumber0Current rating value. Use with v-model. A value of 0 represents no rating selected.
maxnumber5Total number of stars to render.
stepnumber1Granularity of selectable values. Supported: 1, 0.5, 0.25, 0.2, 0.1. Invalid values warn in development and fall back to 1.
readonlybooleanfalseRenders the current value without allowing interaction.
disabledbooleanfalseApplies disabled styling and suppresses all interaction.
ariaLabelstring'Rating'Accessible label applied to the root role="radiogroup" element.
size'sm' | 'md' | 'lg' | numberStar size. Named presets scale size and gap together. A number sets the star size in pixels only.
colorstringFilled and partial star color. Accepts any CSS color value. Sets --vrk-color-filled as an inline style.
emptyColorstringEmpty star track color. Accepts any CSS color value. Sets --vrk-color-empty as an inline style.
hoverColorstringHover state color. Inherits from color when omitted. Consumer CSS overriding --vrk-color-hover always takes precedence.

Events

EventPayloadDescription
update:modelValuenumberEmitted on every value change. Powers v-model.
changenumberEmitted when the user commits a rating via click or touch. Not emitted during keyboard navigation.
hovernumberEmitted on every star enter/leave. Value is 0 when the pointer leaves the component.
focusEmitted when keyboard focus enters the component.
blurEmitted when keyboard focus leaves the component.

Slots

SlotSlot PropsDescription
filled{ star: number }Content rendered in the filled layer of each star. star is the 1-based index (1 … max).
empty{ star: number }Content rendered in the empty (track) layer of each star. star is the 1-based index (1 … max).

Both slots default to the Unicode star character (★) when omitted. Slot content must be inline-level — see Custom Icon Slots.

Keyboard Navigation

KeyAction
ArrowRightIncrement by step (LTR) / Decrement by step (RTL)
ArrowLeftDecrement by step (LTR) / Increment by step (RTL)
HomeSet rating to 0
EndSet rating to max

TypeScript

All public types are exported from the package root:

ts
import type {
  RatingValue,
  RatingProps,
  RatingEmits,
  RatingSlotProps,
  RatingSlots,
  RatingSize,
} from 'vue-rating-kit'

Typed ref:

ts
import { ref } from 'vue'
import type { RatingValue } from 'vue-rating-kit'

const rating = ref<RatingValue>(0)

Typed slot content:

ts
import type { RatingSlotProps } from 'vue-rating-kit'

function renderIcon(props: RatingSlotProps) {
  return props.star <= activeRating ? '❤️' : '🤍'
}

CSS Custom Properties

VariableDefaultDescription
--vrk-color-filled#f5a623Filled and partial star color
--vrk-color-empty#d3d3d3Empty star track color
--vrk-color-hover#f5c842Hover highlight color (consumer-level override)
--vrk-color-disabled#a9a9a9Disabled star track color
--vrk-star-size2remStar size
--vrk-star-gap0.25remSpace between stars
--vrk-focus-outline2px solid currentColorKeyboard focus ring

CSS custom properties always take precedence over component props. See CSS Custom Properties for usage.

Released under the MIT License.