A rating component that allows users to view and provide ratings using customizable symbols. It supports fractional values, hover previews, keyboard navigation, single-selection mode, and integrates with forms as a number input.

Slots
symbol — Slot for projecting custom rating symbol elements. When used, the number of symbols determines the `max` value.
value-label — Renders content after the symbols, such as the value as text.
CSS Parts
base — The main wrapper which holds the symbols and the value label.
label — The label of the rating.
value-label — The wrapper of the `value-label` slot.
symbols — A wrapper for all rating symbols.
symbol — The part of the encapsulated default symbol.
full — The part of the encapsulated full symbols.
empty — The part of the encapsulated empty symbols.

Whether to reset the rating when the user selects the same value.

allowReset: boolean

Whether to show a preview of the value when hovering over the symbols.

hoverPreview: boolean

The label of the control.

label: string | undefined

The maximum value for the rating.

With projected symbols, the maximum value is the number of symbols. A maximum below the value also lowers the value.

max: number

Whether the rating is read-only. A read-only rating shows its value but ignores user input.

readOnly: boolean

Whether only the symbol at the value is full, instead of all symbols up to it. It also sets step to 1 and rounds the value up.

single: boolean

The minimum value change allowed.

Valid values are in the interval between 0.001 and 1 inclusive. The component clamps a value outside of the interval to the closest bound. In single selection mode, the step is always 1.

step: number

The value of the rating, clamped between 0 and max.

value: number

The format of the aria-valuetext of the rating. {0} stands for the value and {1} for the maximum value.

Use it for screen readers and for localization.

valueFormat: string | undefined

Removes focus from the rating.

blur(): void

Returns void

Sets focus on the rating. A disabled rating does not take the focus.

focus(options: FocusOptions): void

Parameters

  • options: FocusOptions

Returns void

Decrements the value of the control by n steps multiplied by the step factor.

stepDown(n: number): void

Parameters

  • n: number

Returns void

Increments the value of the control by n steps multiplied by the step factor.

stepUp(n: number): void

Parameters

  • n: number

Returns void

Emitted when the user changes the value.

onChange(args: CustomEvent<number>): void

Parameters

Returns void

Emitted when the pointer moves to a new value over the symbols while

onHover(args: CustomEvent<number>): void

Parameters

Returns void