<!DOCTYPE html><html><head><title>Basic Rating</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png"><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v6.css"type="text/css" /></head><body><divid="root"><divclass="sample center"><igc-ratingclass="size-large"label="Rate Experience"max="5"step=".5"hover-preview></igc-rating></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %>
<scriptsrc="src/index.ts"></script>
<% } %>
</body></html>html
This will create a five-star rating component that can be used to input and read data from.
Using Custom Symbols
The IgcRatingComponent component allows you to use custom symbols in place of the default star symbols. If you want to use a different symbol, like SVG, icon or another unicode symbol, you should place IgcRatingSymbolComponent components between the opening and closing brackets of the IgcRatingComponent:
<!DOCTYPE html><html><head><title>Rating w/ Custom Symbol</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png"><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v6.css"type="text/css" /></head><body><divid="root"><divclass="sample center"><igc-ratinglabel="Rate Experience"value="3"step=".5"hover-preview><igc-rating-symbol><igc-iconname="heart"></igc-icon><igc-iconname="empty-heart"slot="empty"></igc-icon></igc-rating-symbol><igc-rating-symbol><igc-iconname="heart"></igc-icon><igc-iconname="empty-heart"slot="empty"></igc-icon></igc-rating-symbol><igc-rating-symbol><igc-iconname="heart"></igc-icon><igc-iconname="empty-heart"slot="empty"></igc-icon></igc-rating-symbol><igc-rating-symbol><igc-iconname="heart"></igc-icon><igc-iconname="empty-heart"slot="empty"></igc-icon></igc-rating-symbol><igc-rating-symbol><igc-iconname="heart"></igc-icon><igc-iconname="empty-heart"slot="empty"></igc-icon></igc-rating-symbol></igc-rating></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %>
<scriptsrc="src/index.ts"></script>
<% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
The number of rating symbols between the opening and closing brackets of the rating component determines the max value.
Single Selection
The Ignite UI for Web Components Rating component has a single selection mode that allows users to provide different icons/elements for the different rating values. In this case, only one of the icons/elements can be selected and reflect the feedback given by the user.
<!DOCTYPE html><html><head><title>Single Selection Rating</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png"><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v6.css"type="text/css" /></head><body><divid="root"><divclass="sample center"><igc-ratinglabel="Rate Experience"single><igc-rating-symbol><div>😣</div><divslot="empty">😣</div></igc-rating-symbol><igc-rating-symbol><div>😔</div><divslot="empty">😔</div></igc-rating-symbol><igc-rating-symbol><div>😐</div><divslot="empty">😐</div></igc-rating-symbol><igc-rating-symbol><div>🙂</div><divslot="empty">🙂</div></igc-rating-symbol><igc-rating-symbol><div>😆</div><divslot="empty">😆</div></igc-rating-symbol></igc-rating></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %>
<scriptsrc="src/index.ts"></script>
<% } %>
</body></html>html
Keep in mind that the step attribute doesn't work with single selection mode.
Empty & Selected
The Ignite UI for Web Components Rating component allows users to use different icons/elements for the empty and the selected state of a single rating value. It is mandatory to provide 2 icons for each slot (empty and full) when declaring a symbol, even if they are the same. For instance:
<!DOCTYPE html><html><head><title>Empty State Rating</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png"><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v6.css"type="text/css" /></head><body><divid="root"><divclass="sample center"><igc-rating><igc-rating-symbol><igc-iconname="bandage"></igc-icon><igc-iconname="bacteria"slot="empty"></igc-icon></igc-rating-symbol><igc-rating-symbol><igc-iconname="bandage"></igc-icon><igc-iconname="bacteria"slot="empty"></igc-icon></igc-rating-symbol><igc-rating-symbol><igc-iconname="bandage"></igc-icon><igc-iconname="bacteria"slot="empty"></igc-icon></igc-rating-symbol><igc-rating-symbol><igc-iconname="bandage"></igc-icon><igc-iconname="bacteria"slot="empty"></igc-icon></igc-rating-symbol><igc-rating-symbol><igc-iconname="bandage"></igc-icon><igc-iconname="bacteria"slot="empty"></igc-icon></igc-rating-symbol></igc-rating></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %>
<scriptsrc="src/index.ts"></script>
<% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Configuration
Single
Turns on the single visual mode for the rating. Useful when using symbols that communicate unique values, like feedback emoji faces.
Value
The value attribute sets the current value of the component.
Label
The label attribute allows setting the label value of the rating component.
Value Format
A format string which sets aria-valuetext. All instances of it will be replaced with the current value of the control. Important for screen-readers and useful for localization.
Max Value
The max attribute sets the maximum allowed value of the rating component.
Step
The step attribute sets the allowed fraction of steps between two symbols. Useful when splitting the rating symbols in halves.
Hover Preview
The hover-preview attribute makes the component show the possible outcome of user selection on hover. It is useful when you want to give instant feedback about what the selected value could be.
Read-Only
The readOnly attribute allows the users to set the IgcRatingComponent in read-only mode. This attribute is useful when you want to use the component for information purposes only.
Disabled
The disabled attribute disables the component, making it impossible to select a value using the mouse or keyboard.
Methods
Step Up
The stepUp method increments the value of the component by n steps. Determined by the step factor.
Step Down
The stepDown method decrements the value of the component by n steps. Determined by the step factor.
Events
The IgcRatingComponent component emits two separate events - igcHover and igcChange.
Hover Event
The igcHover event is fired when hovering over a symbol. It provides the value of the symbol under the mouse cursor. Useful for creating custom value labels and readouts.
Change Event
The igcChange event is fired when the selected value changes.
Styling
The IgcRatingComponent component exposes CSS parts for almost all of its inner elements. The following table lists all of the exposed CSS parts:
Name
Description
base
The main wrapper which holds all of the rating elements.
<!DOCTYPE html><html><head><title>Styled Rating</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png"><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v6.css"type="text/css" /></head><body><divid="root"><divclass="sample center"><igc-ratingclas="size-large"label="Styled Rating"value="2.5"step=".5"hover-preview></igc-rating></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %>
<scriptsrc="src/index.ts"></script>
<% } %>
</body></html>html