Rating
The Ignite UI for Angular Rating is a form-associated component that lets users view and select a score on a scale of stars or custom symbols.
In Angular, the Rating is the igc-rating web component from igniteui-webcomponents. Bind it to Angular forms with the IgcFormControlDirective.
Live Demo
Anatomy
The Rating is built from Label and Value, where the Value is the number of the rating scale. The label shows when you set label. Set max to change the number of symbols (5 by default).
2. Rating Icon: indicates selected item
3. Rating Icon: indicates half selected item
4. Rating Icon: indicates unselected item
The igc-rating element renders the label and a slider that holds the symbols. Without projected symbols, it renders one star for each point of max:
igc-rating
└─ #shadow-root
├─ label[part="label"] // hidden when label isn't set
└─ div[part="base"][role="slider"]
├─ div[part="symbols"] // aria-hidden="true"
│ └─ slot[name="symbol"] // projected igc-rating-symbol elements
│ └─ igc-rating-symbol × max // default stars when nothing is projected
│ └─ #shadow-root
│ ├─ div[part="symbol full"] // star_filled icon, clipped to the value
│ └─ div[part="symbol empty"] // star_outlined icon, clipped to the rest
└─ label[part="value-label"]
└─ slot[name="value-label"] // hidden when the slot is empty
Each igc-rating-symbol renders its default slot in the full part and its empty slot in the empty part.
Getting Started
To use the Angular Rating, follow the Ignite UI for Angular Getting Started topic for the basic project setup, then add the component for your target platform.
If your project doesn’t use Ignite UI for Angular yet, run ng add igniteui-angular. Then install the igniteui-webcomponents package, which provides the Rating:
npm install igniteui-webcomponents
Register the IgcRatingComponent, and add CUSTOM_ELEMENTS_SCHEMA to the Angular component that renders igc-rating:
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { defineComponents, IgcRatingComponent } from 'igniteui-webcomponents';
defineComponents(IgcRatingComponent);
@Component({
selector: 'app-product-rating',
template: '<igc-rating label="Rate this product"></igc-rating>',
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class ProductRatingComponent {}
The Ignite UI for Angular theme styles igc-rating, so the Rating follows the theme that you include with the theme() mixin.
The Rating renders five stars and starts with a value of 0.
Usage
Use the Angular Rating to collect a score for a product, a service, or an experience, or to show an average score that users can’t change.
Hover Preview
Set hoverPreview to fill the symbols up to the value under the pointer before the user clicks. When the pointer leaves the symbols, the Angular Rating shows its value again. A read-only or disabled Rating shows no preview.
While the preview is on, the Rating emits igcHover with the value under the pointer:
<igc-rating hover-preview label="Rate this article" (igcHover)="onHover($event)"></igc-rating>
public hint = '';
public onHover(event: Event) {
this.hint = `${(event as CustomEvent<number>).detail} stars`;
}
Reset
By default, a click on the current value keeps the value. Set allowReset to reset the Angular Rating to 0 when the user clicks the current value again.
<igc-rating allow-reset label="Rate this song"></igc-rating>
Read-Only
Set readOnly to show a score that users can’t change, such as the average of all reviews. The value can be any number in the range, so a value of 4.3 fills four symbols and 30% of the fifth. A read-only Angular Rating stays in the tab order, and assistive technology announces it as read-only.
<igc-rating readonly value="4.3" label="Average rating"></igc-rating>
Layout
The label property renders a visible label above the symbols and names the Angular Rating for assistive technology. To show custom content next to the symbols, such as the current score, place it in the value-label slot:
<igc-rating [value]="score" label="Rate this product" (igcChange)="onScoreChange($event)">
<span slot="value-label">{{ score }} of 5</span>
</igc-rating>
Give every Angular Rating an accessible name, and describe its value in words that fit the scale.
When the Rating has no visible label, set aria-label on it, or, with igniteui-webcomponents 7.4.1 and later, associate a <label> element with it. Assistive technology reads the value as “3 of 5” by default. Set valueFormat to replace this text: the Rating replaces {0} with the value and {1} with max, which also lets you localize the text.
<igc-rating aria-label="Delivery speed" value-format="{0} out of {1} stars"></igc-rating>
Leave label unset to hide the label, or use the value-label slot to show the score.
Interaction States
The Angular Rating is enabled by default. Set disabled to turn it off:
<igc-rating disabled value="3" label="Rate this product"></igc-rating>
Empty/Full State
The value of the Angular Rating sets how full its symbols are. A value of 0, the default, shows all symbols empty, and a value equal to max shows all symbols full.
Bind the value as a property, and update it in the igcChange handler:
<igc-rating [value]="score" max="10" label="Rate this movie" (igcChange)="onScoreChange($event)"></igc-rating>
public score = 3;
public onScoreChange(event: Event) {
this.score = (event as CustomEvent<number>).detail;
}
Set step to 0.5 to let users select half stars:
<igc-rating step="0.5" value="3.5" label="Rate your stay"></igc-rating>
Size
The Rating is available in three sizes - Small, Medium and Large. The small, medium, and large sizes render 18px, 24px, and 36px symbols, and the Angular Rating uses the medium size by default. Set the --ig-size CSS variable to --ig-size-small, --ig-size-medium, or --ig-size-large to choose a size. For a size outside these presets, set --ig-rating-symbol-size:
.rating-small {
--ig-size: var(--ig-size-small);
}
.rating-large {
--ig-size: var(--ig-size-large);
}
.rating-custom {
--ig-rating-symbol-size: 3rem;
}
<igc-rating class="rating-large" label="Rate this product"></igc-rating>
Symbols
By default, the Angular Rating renders star icons. To use other symbols, place one igc-rating-symbol element for each point of the scale inside the Rating. Each rating symbol shows its default slot content in the part of the symbol that the value covers and its empty slot content in the rest, so fill both slots, even with the same content. The number of rating symbols sets max, and the Rating ignores the max that you set.
The following rating uses heart icons that you register with registerIconFromText from igniteui-webcomponents. Use igc-icon in the rating symbols, because the Rating sizes igc-icon elements to the symbol size:
<igc-rating label="Rate this recipe">
@for (i of [1, 2, 3, 4, 5]; track i) {
<igc-rating-symbol>
<igc-icon name="favorite" collection="material"></igc-icon>
<igc-icon name="favorite_border" collection="material" slot="empty"></igc-icon>
</igc-rating-symbol>
}
</igc-rating>
The Rating colors icons and text with the full and empty symbol colors of the theme. It renders content other than an Icon in the empty slot in grayscale, so the same emoji in both slots looks selected or empty.
Single Selection
Set single to show only the selected symbol as full. Use single selection with symbols that each stand for one distinct value, such as a scale of faces. In single selection, the Angular Rating uses a step of 1 and rounds a fractional value up.
<igc-rating single label="How was your experience?">
@for (face of faces; track face) {
<igc-rating-symbol>
<span>{{ face }}</span>
<span slot="empty">{{ face }}</span>
</igc-rating-symbol>
}
</igc-rating>
public faces = ['😣', '😔', '😐', '🙂', '😆'];
Forms
To bind the Rating with ngModel or formControlName, Angular needs an implementation of its ControlValueAccessor interface. Ignite UI for Angular provides it as the standalone IgcFormControlDirective, which attaches to igc-rating elements with ngModel or formControlName. Import it together with FormsModule or ReactiveFormsModule:
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { IgcFormControlDirective } from 'igniteui-angular/directives';
// import { IgcFormControlDirective } from '@infragistics/igniteui-angular/directives'; for licensed package
@Component({
selector: 'app-review-form',
template: `
<form>
<igc-rating name="userRating" [(ngModel)]="review.rating" label="Your rating"></igc-rating>
</form>
`,
imports: [FormsModule, IgcFormControlDirective],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class ReviewFormComponent {
public review = { rating: 0 };
}
With reactive forms, bind the Rating with formControlName:
<form [formGroup]="reviewForm">
<igc-rating formControlName="rating" label="Your rating"></igc-rating>
</form>
The directive updates the model on igcChange, marks the control as touched when the Rating loses focus, and disables the Rating when you disable the form control.
The Rating has no required validation. To require a score, check that the value is greater than 0 before you submit the data.
Do/Don’t
The star is a very recognizable ranking symbol, and people may not associate other symbols with a rating scale. If you replace the star with a custom symbol, make sure that its purpose is clear. Avoid colors with poor contrast, like similar shades of the same color or combinations that create chromatic aberrations. The Icons selections should be emphasized and should have a good visual distinct appearance.

Do
Use stars or another symbol that users associate with a rating scale.
Don’t
Avoid symbols whose meaning as a score isn’t clear.

Do
Make the selected symbols stand out from the empty ones.
Don’t
Avoid similar shades for the selected and the empty symbols.
Properties
The Angular Rating exposes the following properties. See the API reference for the complete type definitions.
| Name | Type | Default | Description |
|---|---|---|---|
value |
number |
0 |
The current value, from 0 to the maximum value. |
max |
number |
5 |
The maximum value and the number of default symbols. Projected rating symbols set it to their count. |
step |
number |
1 |
The smallest change of the value, from 0.001 to 1. |
label |
string |
— | The visible label, which also names the rating. |
valueFormat |
string |
— | The format of aria-valuetext. {0} stands for the value and {1} for the maximum value. |
hoverPreview |
boolean |
false |
Whether the rating previews the value under the pointer. |
readOnly |
boolean |
false |
Whether the user can’t change the value. |
single |
boolean |
false |
Whether only the selected symbol is shown as full. |
allowReset |
boolean |
false |
Whether a click on the current value resets the rating to 0. |
disabled |
boolean |
false |
Whether the rating is disabled. |
invalid |
boolean |
false |
Marks the rating as invalid through the ig-invalid custom state. The Rating themes don’t style this state. |
name |
string |
— | The name under which a form submits the value. |
Methods
The Angular Rating exposes the following methods. The step methods change the value without emitting a change event.
| Method | Description |
|---|---|
stepUp |
Increases the value by the given number of steps. The number defaults to 1. |
stepDown |
Decreases the value by the given number of steps. The number defaults to 1. |
checkValidity |
Returns whether the value is valid, and emits invalid when it isn’t. |
reportValidity |
Returns whether the value is valid, and shows the browser validation message when it isn’t. |
setCustomValidity |
Sets a custom validation message. The rating is invalid while the message isn’t empty. |
Events
The Angular Rating emits the following events. It doesn’t emit them when you set the value or call a method.
| Name | Type | Description |
|---|---|---|
igcChange |
CustomEvent<number> |
Emitted when the user changes the value. The event detail holds the new value. |
igcHover |
CustomEvent<number> |
Emitted when the hover preview is on and the pointer moves to another value. The event detail holds the value under the pointer. |
Styling
The Angular Rating takes its colors and its symbol size from the theme. Change them with the following CSS variables:
| Variable | What it changes |
|---|---|
--ig-rating-symbol-full-color |
The color of the full symbols: the default stars, icons, and text. |
--ig-rating-symbol-empty-color |
The color of the empty symbols. |
--ig-rating-label-color |
The color of the label. |
--ig-rating-value-label |
The color of the value label. |
--ig-rating-symbol-size |
The size of the symbols. |
--ig-size |
The size preset: --ig-size-small, --ig-size-medium, or --ig-size-large. |
--ig-rating-disabled-full-symbol-color |
The color of the full symbols when the rating is disabled. |
--ig-rating-disabled-empty-symbol-color |
The color of the empty symbols when the rating is disabled. |
--ig-rating-disabled-label-color |
The color of the label and the value label when the rating is disabled. |
--ig-rating-symbol-full-filter |
The CSS filter of full symbols other than icons, such as emoji, when the rating is disabled. |
--ig-rating-symbol-empty-filter |
The CSS filter of empty symbols other than icons, such as emoji, when the rating is disabled. |
The igc-rating element exposes the following CSS parts:
| Part | What it styles |
|---|---|
base |
The slider that holds the symbols and the value label. |
label |
The label. |
value-label |
The container of the value-label slot. |
symbols |
The container of all symbols. |
symbol |
Each default symbol. |
full |
The full layer of each default symbol. |
empty |
The empty layer of each default symbol. |
The igc-rating element exports the symbol, full, and empty parts of its default stars only. To style projected rating symbols, use the symbol, full, and empty parts of the igc-rating-symbol element.
Sass Theming
Create a theme with the rating-theme function and include it with the tokens() mixin. The function accepts parameters such as $symbol-full-color, $symbol-empty-color, $label-color, and $symbol-size, and the mixin emits the matching --ig-rating-* variables in the scope where you include it.
@use "igniteui-angular/theming" as *;
$custom-rating-theme: rating-theme(
$symbol-full-color: #e41c77,
$symbol-empty-color: #a9b8cc,
$label-color: #344b65
);
:host {
@include tokens($custom-rating-theme);
}
CSS Variables
Set the CSS variables on a Rating or on a container when you need local styling without a Sass build step, and use the CSS parts for other styles:
igc-rating {
--ig-rating-symbol-full-color: #e41c77;
--ig-rating-symbol-empty-color: #a9b8cc;
}
igc-rating::part(label) {
font-weight: 600;
}
igc-rating-symbol::part(empty) {
opacity: 0.6;
}
Styling with Tailwind
You can style the Angular Rating with Tailwind arbitrary properties that set its CSS variables. Make sure to set up Tailwind first:
<igc-rating
label="Rate this product"
class="[--ig-rating-symbol-full-color:#7B9E89] [--ig-rating-symbol-size:2rem]"
></igc-rating>
Accessibility
The Angular Rating is a slider: users reach it with the Tab key, change its value with the arrow keys, and hear the value through its ARIA attributes.
Keyboard Interaction
The Angular Rating is a single tab stop, because only the slider element inside it, the base part, receives focus. A disabled Rating leaves the tab order. A read-only Rating stays in the tab order but ignores the following keys, so they keep their default browser actions, such as page scrolling.
| Key | Action |
|---|---|
| Tab / Shift + Tab | Moves the focus to the next or the previous focusable element. The Rating doesn’t handle these keys, so it never traps the focus. |
| Arrow Right | Increases the value by one step. In a right-to-left layout, decreases it. |
| Arrow Left | Decreases the value by one step. In a right-to-left layout, increases it. |
| Arrow Up | Increases the value by one step. |
| Arrow Down | Decreases the value by one step. |
| Home | Sets the value to one step, the lowest value that a click can select. |
| End | Sets the value to the maximum value. |
The Angular Rating handles these keys on keydown:
- It prevents their default action, so the arrow keys, Home, and End don’t scroll the page while the Rating has focus.
- A key that you hold repeats its action.
- A key that you press together with Shift, Ctrl, Alt, or Meta does nothing.
- The value stays between 0 and the maximum value. A key that would move the value past a bound keeps the value and emits no event.
- Each key that changes the value emits the change event.
With a pointer, a click selects the value under the pointer, rounded up to the next step. A read-only or disabled Rating ignores clicks.
Screen Readers / ARIA
The Angular Rating renders one focusable element, the base part, with the slider role. Its tabindex is 0, or -1 when the Rating is disabled, and it carries the following value attributes:
| Attribute | Value |
|---|---|
aria-valuemin |
0 |
aria-valuemax |
The maximum value |
aria-valuenow |
The value, including fractions such as 4.3 |
aria-valuetext |
“3 of 5” by default, or the valueFormat text |
With igniteui-webcomponents 7.3.0 and later, the slider also sets aria-disabled and aria-readonly to expose the disabled and read-only states. With 7.4.1 and later, the slider takes its accessible name from the first of the following:
- The
aria-labelledbyattribute of the host. - A
<label>element that is bound throughfor, or that wraps the Rating. A click on the label focuses the slider. - The
labelproperty, which renders a visible label that the slider references througharia-labelledby. - The
aria-labelattribute of the host. The slider ignores it when thelabelproperty is set.
The Angular Rating also behaves as follows for assistive technology:
- The
symbolspart setsaria-hidden="true", so the symbols, including projected icons and emoji, are hidden and don’t need text alternatives. The value reaches assistive technology only througharia-valuenowandaria-valuetext. - The
value-labelslot renders inside the slider. Screen readers read the value fromaria-valuetext, so describe the value withvalueFormatrather than with the slot content. - The Rating doesn’t use a live region. A changed value reaches assistive technology only through the slider attributes.
- The Rating doesn’t set
aria-invalid, so a custom validation message isn’t exposed as an invalid state.
Accessibility Compliance
Infragistics documents Ignite UI for Angular accessibility support for Section 508 and WCAG 2.1 guideline areas in the Accessibility Compliance topic.
| Criterion | How the component complies |
|---|---|
| 1.1.1 Non-text Content | The symbols are hidden from assistive technology, and the slider exposes the value as text through aria-valuetext. |
| 1.3.1 Info and Relationships | The visible label of the label property is associated with the slider through aria-labelledby. |
| 1.4.1 Use of Color | The default symbols show a filled star for the selected part of the scale and an outlined star for the rest, so the value doesn’t depend on color alone. |
| 2.1.1 Keyboard | The arrow keys, Home, and End change the value, so users can rate without a pointer. |
| 2.1.2 No Keyboard Trap | The Rating is a single tab stop and doesn’t handle the Tab key, so Tab and Shift + Tab move the focus out of it. |
| 2.4.7 Focus Visible | The Rating themes don’t remove the browser focus indicator from the focused slider. |
| 4.1.2 Name, Role, Value | The slider exposes the slider role, its value through aria-valuenow and aria-valuetext, and the name that you provide. With igniteui-webcomponents 7.3.0 and later, it also exposes the disabled and read-only states. |
Your responsibilities:
- Name every Rating with the
labelproperty, an associated<label>element, oraria-label. See Layout. - Set
valueFormatwhen “3 of 5” doesn’t describe the scale, or when the page uses another language. - With custom symbols, make the full and the empty symbols differ in shape or fill, not only in color, and keep a contrast ratio of at least 3:1 against the background, as 1.4.11 Non-text Contrast requires.
- When you restyle the
basepart, keep a visible focus indicator. - Keep the pointer targets large enough. Each value is a target as wide as one symbol, or half a symbol with a step of 0.5. The small size renders 18px symbols, below the 24 by 24 CSS pixels of 2.5.8 Target Size (Minimum), so prefer the medium or the large size for pointer and touch input.
- Don’t put information only in the hover preview, because keyboard users don’t see it.
- When you validate the rating with a custom validation message, also show the message as text next to the Rating, as 3.3.1 Error Identification requires, because the Rating doesn’t set
aria-invalid.
Differences from the WAI-ARIA slider pattern:
- Home sets the value to one step instead of to
aria-valuemin, which is 0. Use Arrow Down to reach 0. - The Rating doesn’t support Page Up and Page Down, which the pattern lists as optional keys.
Troubleshooting
Use these answers when a Angular Rating doesn’t behave as expected.
Why doesn’t the change event fire when I set the value?
The Angular Rating emits the change event only for user input: a click or a key. Setting the value in code, or calling the step methods, changes the value without the event, so update your own state where you set the value.
Why doesn’t a click on the current value reset the rating?
The Angular Rating keeps the value on a click on the current value, unless you set allowReset. Before igniteui-webcomponents 4.7.0, a click on the current value always reset the rating; set allowReset to keep that behavior after an upgrade.
Why doesn’t the hover event fire?
The Angular Rating emits the hover event only while hoverPreview is on, and not when the Rating is read-only or disabled. Set hoverPreview to receive the event.
API References
Dependencies
The Angular Rating requires a theme to apply its colors and symbol sizes. See the framework-specific setup in Getting Started.
The Rating requires the igniteui-webcomponents package, and Angular forms binding requires the IgcFormControlDirective. The theme() mixin of Ignite UI for Angular includes the igc-rating styles unless you exclude igc-rating through its $exclude parameter.
Additional Resources
The following resources provide more Angular Rating guidance and project support:
Related Components
The Angular Rating collects a score on a scale of symbols. Use these components when the input needs a different form:
- Slider - Use Slider when users pick a precise number from a continuous range, such as a price or a volume.
- Radio Group - Use Radio Group when each option needs a text label, such as Poor, Fair, and Good.
- Icon - Use Icon to draw the custom symbols of a Rating.
FAQ
These questions cover common Angular Rating setup, accessibility, and usage scenarios.
Yes. Set the step property of the Angular Rating to 0.5, and a click on the left half of a star selects the half value in a left-to-right layout. The arrow keys then change the value of the Angular Rating in steps of 0.5.
Set the readOnly property of the Angular Rating and set its value to the average, such as 4.3. The Angular Rating fills the symbols in part for a fractional value, stays focusable, and ignores clicks and keys.
Yes. The Angular Rating is a single tab stop with the slider role, the arrow keys, Home, and End change its value, and screen readers read the value through aria-valuetext. Give the Angular Rating an accessible name with the label property or aria-label, and set valueFormat to describe the value in words.
Yes. Import the IgcFormControlDirective from igniteui-angular/directives to bind the Angular Rating with ngModel or formControlName. The directive updates the model when the user changes the value and disables the Rating when you disable the form control.