Class IgcRatingComponent

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.

<!-- Basic rating -->
<igc-rating value="3" max="5" label="Rate this product"></igc-rating>
<!-- Half-star rating with hover preview -->
<igc-rating step="0.5" hover-preview value-format="{0} out of {1} stars"></igc-rating>
<!-- Custom symbols via projected rating symbols -->
<igc-rating>
<igc-rating-symbol>
<igc-icon name="heart_filled" collection="default"></igc-icon>
<igc-icon name="heart_outlined" collection="default" slot="empty"></igc-icon>
</igc-rating-symbol>
<igc-rating-symbol>
<igc-icon name="heart_filled" collection="default"></igc-icon>
<igc-icon name="heart_outlined" collection="default" slot="empty"></igc-icon>
</igc-rating-symbol>
</igc-rating>

igc-rating

symbol - Slot for projecting custom igc-rating-symbol elements. When used, the number of symbols determines the max value.

value-label - Slot for custom content displayed alongside the rating value.

igcChange - Emitted when the value of the control changes.

igcHover - Emitted when hover is enabled and the user mouses over a symbol of the rating.

base - The main wrapper which holds all of the rating elements.

label - The label part.

value-label - The value label part.

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.

--symbol-size - The size of the symbols.

--symbol-full-color - The color of the filled symbol.

--symbol-empty-color - The color of the empty symbol.

--symbol-full-filter - The filter(s) used for the filled symbol.

--symbol-empty-filter - The filter(s) used for the empty symbol.

Hierarchy

Hierarchy

  • FormAssociatedElementInterface<this> & EventEmitterInterface<
        IgcRatingComponentEventMap,
        this,
    > & LitElement<this>
    • IgcRatingComponent

Constructors

Properties

allowReset: boolean = false

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

allow-reset

false
disabled: boolean

The disabled state of the component.

false
hoverPreview: boolean = false

Sets hover preview behavior for the component

hover-preview

invalid: boolean

Sets the control into invalid state (visual state only).

false
label?: string

The label of the control.

label

name: string

The name attribute of the control.

readOnly: boolean = false

Makes the control a readonly field.

readonly

valueFormat?: string

A format string which sets aria-valuetext. Instances of '{0}' will be replaced with the current value of the control and instances of '{1}' with the maximum value for the control.

Important for screen-readers and useful for localization.

value-format

styles: CSSResult[] = ...
tagName: "igc-rating" = 'igc-rating'

The tagName read-only property of the Element interface returns the tag name of the element on which it's called.

MDN Reference

Accessors

  • get defaultValue(): unknown

    Returns unknown

  • set defaultValue(value: unknown): void

    The initial value of the component.

    Parameters

    • value: unknown

    Returns void

  • get form(): HTMLFormElement | null

    Returns the HTMLFormElement associated with this element.

    Returns HTMLFormElement | null

  • get validationMessage(): string

    A string containing the validation message of this element.

    Returns string

  • get validity(): ValidityState

    Returns a ValidityState object which represents the different validity states the element can be in, with respect to constraint validation.

    Returns ValidityState

  • get willValidate(): boolean

    A boolean value which returns true if the element is a submittable element that is a candidate for constraint validation.

    Returns boolean

Methods

  • Type parameters

    Type Parameters

    Parameters

    • type: K
    • listener: (this: HTMLElement, ev: M[K]) => any
    • options: boolean | AddEventListenerOptions

    Returns void

  • Parameters

    • type: string
    • listener: EventListenerOrEventListenerObject
    • options: boolean | AddEventListenerOptions

    Returns void

  • Type parameters

    Type Parameters

    • K extends keyof HTMLElementEventMap

    Parameters

    • type: K
    • listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any
    • options: boolean | AddEventListenerOptions

    Returns void

  • Checks for validity of the control and emits the invalid event if it invalid.

    Returns boolean

  • Type parameters

    Type Parameters

    Parameters

    • type: K
    • listener: (this: HTMLElement, ev: M[K]) => any
    • options: boolean | EventListenerOptions

    Returns void

  • Parameters

    • type: string
    • listener: EventListenerOrEventListenerObject
    • options: boolean | EventListenerOptions

    Returns void

  • Type parameters

    Type Parameters

    • K extends keyof HTMLElementEventMap

    Parameters

    • type: K
    • listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any
    • options: boolean | EventListenerOptions

    Returns void

  • Checks for validity of the control and shows the browser message if it invalid.

    Returns boolean

  • Sets a custom validation message for the control. As long as message is not empty, the control is considered invalid.

    Parameters

    • message: string

    Returns void

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

    Parameters

    • n: number = 1

    Returns void

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

    Parameters

    • n: number = 1

    Returns void