Labels in ASP.NET Core Rating Control

23 Jan 20231 minute to read

You can use the showLabel property to display a label that shows the current value of the rating. When the showLabel property is set to true, a label will be displayed.

@using Syncfusion.EJ2.Inputs

<ejs-rating id="rating" value=3 showLabel=true></ejs-rating>

ASP.NET Core Rating Control with Label

Label position

The Rating control allows you to place the label on the top, bottom, left, or right side of the rating using the labelPosition property.

The following label positions are supported:

  • Top: The label is placed on the top of the rating.
  • Bottom: The label is placed on the bottom of the rating.
  • Left: The label is placed on the left side of the rating.
  • Right: The label is placed on the right side of the rating.
@using Syncfusion.EJ2.Inputs

<label>Left Label Position</label><br />
<ejs-rating id="rating1" value=3 showLabel=true labelPosition=Left></ejs-rating><br />

<label>Right Label Position</label><br />
<ejs-rating id="rating2" value=3 showLabel=true labelPosition=Right></ejs-rating><br />

<label>Top Label Position </label><br />
<ejs-rating id="rating3" value=3 showLabel=true labelPosition=Top></ejs-rating><br />

<label>Bottom Label Position</label><br />
<ejs-rating id="rating4" value=3 showLabel=true labelPosition=Bottom></ejs-rating><br />

ASP.NET Core Rating Control with different label positions

Label template

You can use the labelTemplate tag directive to specify a custom template for the Label of the rating. The current value of the rating will be passed as the value property in the template context when building the content of the label. This allows you to include dynamic information about the rating in the template.

@using Syncfusion.EJ2.Inputs

<ejs-rating id="rating" value=3 showLabel=true labelTemplate="<span>${value} Out Of 5</span>"></ejs-rating>

ASP.NET Core Rating Control with Label template