Blazorise Rating component
Ratings provide insight regarding others opinions and experiences with a product.
Rating component can be used to allow the users to share their opinion about the product, documentation page, photo and more.
Examples
Basic
To start with a basic example just define the rating color.<Rating Color="Color.Primary" />
Two-way binding
Binding the selected value to a variable will make it more usable.<Rating Color="Color.Primary" @bind-SelectedValue="" MaxValue="10" />
@code{ int SelectedValue = 7; }
Show Tooltips
By defining the GetTooltip
callback you can show the extra information to the user.
Along with the tooltip Text, it is also possible to control tooltip arrow visibility, multiline mode, and placement.
<Rating Color="Color.Primary" @bind-SelectedValue="" MaxValue="10" GetTooltip="" />
@code { int SelectedValue = 7; RatingTooltip GetTooltip( int value ) { if ( value <= 2 ) return new RatingTooltip( "Very bad" ); else if ( value <= 4 ) return new RatingTooltip( "Bad", TooltipPlacement.Bottom ); else if ( value <= 6 ) return new RatingTooltip( "Fair" ); else if ( value <= 8 ) return new RatingTooltip( "Good", TooltipPlacement.Top, false, false ); else if ( value <= 10 ) return new RatingTooltip( "Very good" ); return null; } }
API
Attributes
Name | Description | Type | Default |
---|---|---|---|
MaxValue |
Maximum rating value that is allowed to be selected. | int | 5 |
ReadOnly |
Prevents modification of the input’s value. | bool | false |
Disabled |
Prevent the user interactions and make it appear lighter. | bool | false |
FullIcon |
Defines the selected icon name. | object | IconName.Star |
EmptyIcon |
Defines the non-selected icon name. | object | IconName.Star |
FullIconStyle |
Defines the selected icon style. | IconStyle? | Solid |
EmptyIconStyle |
Defines the non-selected icon style. | IconStyle? | Regular |
Color |
Defines the color or icons. | Color | Warning |
GetTooltip |
Expression that provides the tooltip for the rating item to have additional user-friendly information.
The expression receives the rating item |
Func<int, RatingTooltip> | null |