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.
Properties
Section titled "Properties"allowReset
Section titled "allowReset"Whether to reset the rating when the user selects the same value.
allowReset: boolean hoverPreview
Section titled "hoverPreview"Whether to show a preview of the value when hovering over the symbols.
hoverPreview: boolean 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 readOnly
Section titled "readOnly"Whether the rating is read-only. A read-only rating shows its value but ignores user input.
readOnly: boolean single
Section titled "single"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 valueFormat
Section titled "valueFormat"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 Methods
Section titled "Methods"Removes focus from the rating.
blur(): void Returns void
focus
Section titled "focus"Sets focus on the rating. A disabled rating does not take the focus.
focus(options: FocusOptions): void Parameters
- options:
FocusOptions
Returns void
stepDown
Section titled "stepDown"Decrements the value of the control by n steps multiplied by
the step factor.
stepDown(n: number): void Parameters
- n:
number
Returns void
stepUp
Section titled "stepUp"Increments the value of the control by n steps multiplied by the
step factor.
stepUp(n: number): void Parameters
- n:
number
Returns void
Events
Section titled "Events"onChange
Section titled "onChange"Emitted when the user changes the value.
onChange(args: CustomEvent<number>): void Parameters
- args:
CustomEvent<number>
Returns void
onHover
Section titled "onHover"Emitted when the pointer moves to a new value over the symbols while
onHover(args: CustomEvent<number>): void Parameters
- args:
CustomEvent<number>