structyl

Rating

stable

Collects a numeric star rating.

Basic usage

Examples

Read-only rating

Use readOnly to display an existing score without interaction.

Custom max and labels

Change max or label text for different scoring systems.

Sizes, colors and custom icons

Rating supports controlled/uncontrolled values, custom labels, max, sizes and colors.

Features

  • Controlled or uncontrolled.
  • Keyboard-focusable items.

Installation

bash
pnpm dlx structyl add rating

API Reference

Rating

Star rating input.

PropTypeDefault
value | defaultValuenumber

Controlled or uncontrolled rating value.

onValueChange(value: number) => void

Called when value changes.

maxnumber

Number of rating items.

5
disabled | readOnlyboolean

Interaction state.

false
namestring

Hidden input name for forms.

size'small' | 'medium' | 'large'

Star size.

'medium'
color'default' | 'primary' | 'success' | 'warning' | 'destructive' | 'muted'

Checked item color.

'primary'
icon | emptyIconReact.ReactNode

Custom checked and unchecked visuals.

getLabelText(value: number) => string

Accessible label generator.

precisionnumber

Documented precision marker for design parity.

classNamestring

Additional Tailwind classes merged with the component defaults.

Rating | structyl