DS0
Components

Rating

A star-based rating input that allows users to provide feedback by selecting a value on a numeric scale.

Overview

Rating renders a row of interactive star icons. Users can click or hover to select a rating. Supports half-star precision, read-only display, and custom icons.

Usage

<Rating value={rating} onChange={setRating} />

Read-only

<Rating value={4.5} readOnly />

Accessibility

KeyAction
ArrowLeft/RightChange rating value
HomeSet to minimum
EndSet to maximum
  • Uses role="radiogroup" with role="radio" for each star
  • Each star has aria-label describing the value

API Reference

PropTypeDefaultDescription
valuenumber0Current rating
onChange(value: number) => voidChange handler
maxnumber5Maximum rating
precision0.5 | 11Value precision
readOnlybooleanfalseRead-only display
size'sm' | 'md' | 'lg''md'Star size
ComponentWhen to Use Instead
SliderContinuous value selection
ToggleBinary on/off

On this page