Toggle Sidebar B
AppearanceLight & dark mode D

Rating

Star rating with fractional display, half-star input, hover preview, and keyboard support. Interactive mode is built on the reka-ui Rating primitives (a radiogroup with one radio per step); readonly mode renders a static star row so any decimal value stays exact.

Default

Interactive 5-star rating with v-model.

Replay preview

Fractional display

Any decimal value renders a partially filled star.

Replay preview

Half-star input

Maps to reka-ui step=0.5, so each star renders two radios: click or arrow onto the left half for a .5 value.

Replay preview
2.5

Show value

Display the numeric value beside the stars. It follows the hover preview while the pointer is over the stars.

Replay preview
4.0

Clearable

Click the current value again to reset the rating to 0.

Replay preview

Click star 3 again to clear

Custom length

Any number of stars via max, which maps to reka-ui length.

Replay preview
7.0

Sizes

sm, default, lg.

Replay preview

Colors

yellow (default), warning, primary, foreground.

Replay preview

Per-star classes

starClass reaches every star wrapper, for hover or transition effects.

Replay preview

Readonly

Display-only, no hover or keyboard.

Replay preview

Disabled

Dimmed and non-interactive for forms.

Replay preview

Composing the primitives

What Rating builds on. Use the reka-ui primitives directly when you need a shape this component does not cover — a different indicator, custom layout, or your own state handling.

Replay preview

Value: 2.5

API Reference

Rating

PropTypeDefaultDescription
modelValuenumber0Current rating. Supports v-model. Clamped to [0, max]. Fractional values render partial fills; in interactive mode a value off the step grid (e.g. 3.7 with step 1) still shows the partial fill but leaves no radio checked.
maxnumber5Number of stars. Forwards to RatingRoot length.
size"sm" | "default" | "lg""default"Star and gap size.
readonlybooleanfalseDisplay-only. Renders a static role="img" star row instead of a radiogroup, so any decimal renders exactly and there are no focus stops.
disabledbooleanfalseDimmed and non-interactive. Forwards to RatingRoot disabled and turns off hover preview.
showValuebooleanfalseRender the numeric value next to the stars. Follows the hover preview.
allowHalfbooleanfalseAllow half-star selection. Maps to reka-ui step=0.5, so arrows also move in 0.5 increments.
clearablebooleanfalseClicking the current value resets the rating to 0. Forwards to RatingRoot clearable.
color"yellow" | "warning" | "primary" | "foreground""yellow"Filled-star color. Default yellow matches the ReUI rating.
classstringundefinedClasses for the root container.
starClassstringundefinedClasses for each star wrapper.
EventDescription
update:modelValueFires on click or keyboard change with the new rating. Enables v-model. With clearable, clicking the current value emits 0.

RatingRoot (reka-ui)

PropTypeDefaultDescription
modelValuenumberundefinedControlled rating value. Supports v-model.
defaultValuenumberundefinedInitial value when uncontrolled.
lengthnumber5How many items (stars) to render. Exposed as the items slot prop.
stepnumber1Increment between selectable values. 0.5 gives two radios per star.
clearablebooleanfalseSelecting the current value resets it to 0.
hoverablebooleanfalseTrack a hover preview; indicators up to the hovered step get data-state="active".
disabledbooleanfalseBlocks selection and hover tracking.
orientation"horizontal" | "vertical""horizontal"Arrow-key axis of the underlying roving focus group.
loopbooleantrueWrap focus from the last item back to the first. Rating passes false.
name / requiredstring / booleanundefinedNative form integration, forwarded to the radio group.
as / asChildstring | Component / booleanundefinedRender element or delegate rendering to the child.
EventDescription
update:modelValueFires with the newly selected value.
SlotDescription
defaultSlot props { items, modelValue }, where items is [1..length].

RatingItem (reka-ui)

PropTypeDefaultDescription
itemnumber1-based index of this star. Required.
as / asChildstring | Component / boolean"label"Render element. Rating renders it as a span.
SlotDescription
defaultSlot prop { steps }: the selectable stops inside this star, e.g. [0.5, 1] when step is 0.5.

RatingItemIndicator (reka-ui)

PropTypeDefaultDescription
stepnumberThe stop this indicator represents. Required. Renders a radio button.
as / asChildstring | Component / booleanundefinedRender element or delegate rendering to the child.
EventDescription
data-state="active"Data attribute, not an event: present when step <= the hovered value (or the model value when not hovering). Style the filled state with data-[state=active]:*.
SlotDescription
--reka-rating-item-step-widthCSS variable: how much of the star this stop covers (50% for a half step). Apply it as the indicator width with overflow-hidden to clip the icon.
--reka-rating-item-step-opacityCSS variable: 0 for fractional stops that are neither focused, hovered nor selected. Rating does not bind it — it derives from document.activeElement and so mismatches during hydration; colouring the inactive state (text-transparent until data-state="active") covers the same need.
--reka-rating-item-step-z-indexCSS variable: stacking order, putting the smaller stop on top so pointer hit-testing picks the half first.

Accessibility

Keyboard shortcuts and ARIA behavior.

Shortcut Description
TabEnters or leaves the rating. Roving tabindex: only the selected star (or the first) is a tab stop.
ArrowRightMoves to the next star and selects it (0.5 steps with allowHalf).
ArrowLeftMoves to the previous star and selects it.
ArrowUpSame as ArrowRight.
ArrowDownSame as ArrowLeft.
SpaceSelects the focused star.
HomeSets the rating to 0.
EndSets the rating to max.
  • Interactive ratings render a radiogroup with one radio per step; each radio is labelled "N of max" and exposes aria-checked.
  • Readonly ratings render a static role="img" with an aria-label describing the value — no radios and no focus stops.
  • Provide an aria-label (e.g. "Product rating") to name the group; it forwards to the root element.
  • Arrows cannot reach 0 because there is no radio for it — use Home, or clearable to clear by clicking the current value.
  • Star icons are aria-hidden; the value is conveyed by the radios (interactive) or the root aria-label (readonly).