Skip to content

RatingProps

allowClear?: boolean;

Re-selecting the current value clears to 0.

true when interactive

"aria-describedby"?: string;

ids of external error/help text.


className?: string;

defaultValue?: number;

Uncontrolled initial score. Ignored when value is provided.


dir?: "ltr" | "rtl";

Flips the fill origin.

inherited from the DOM

disabled?: boolean;

emptyIcon?: RatingIcon;

Empty/track icon.

same as icon, dimmed via --rx-rating-empty-filter


formatLabel?: (value, max) => string;

Formats the default accessible name.

ParameterType
valuenumber
maxnumber

string

${value} out of ${max}


formatOptionLabel?: (value, max) => string;

Accessible name for one option, e.g. for aria-label on each radio.

ParameterType
valuenumber
maxnumber

string


icon?: RatingIcon;

Filled icon. A function receives per-icon state.

a built-in star

id?: string;

Base id; option inputs derive ${id}-1, ${id}-2, …


invalid?: boolean;

Sets aria-invalid and data-invalid on the group.


label?: string;

Accessible name for the group.


max?: number;

Number of icons rendered. Positive integer.

5

name?: string;

Radio group name; also emits a value readable by a native <form>.


onBlur?: (event) => void;

Fires when focus leaves the whole group, not when moving between icons.

ParameterType
eventFocusEvent<HTMLElement>

void


onChange?: (value) => void;

Providing this makes the component interactive.

ParameterType
valuenumber

void


onHoverChange?: (value) => void;

Hover/keyboard preview; null when the preview ends.

ParameterType
valuenumber | null

void


onWarn?: (warning) => void;

Called in development whenever a prop is coerced to keep the component functional — see RatingWarning. The coerced result still renders, so this never changes what the user sees; it only surfaces the mistake. When omitted, the same warnings go to console.warn. The entire path is stripped from production builds, so this is a no-op there.

ParameterType
warningRatingWarning

void


precision?: number;

Quantization grid: 1 = whole icons, 0.5 = halves, 0 = continuous.

0

readOnly?: boolean;

Force read-only even when onChange is present.

!onChange


required?: boolean;

rounding?: RatingRounding;

Direction of the snap onto the grid.

'nearest'

style?: CSSProperties;

value?: number;

Controlled score. Clamped to [0, max]; NaN/Infinity become 0.