Rating
DRating renders daisyUI's
Stars
Value: 3
<DRating @bind-Value="_stars" GroupName="demo-stars" />
<span class="badge badge-lg badge-primary">Value: @_stars</span>
@code {
private double _stars = 3;
}Hearts
Value: 2
<DRating Icon="DaisyRatingIcon.Heart" Max="4" @bind-Value="_hearts" GroupName="demo-hearts" />
<span class="badge badge-lg badge-error">Value: @_hearts</span>
@code {
private double _hearts = 2;
}Sizes— rating-xs to rating-lg
<DRating Size="DaisySize.ExtraSmall" Value="3" GroupName="size-xs" />
<DRating Size="DaisySize.Small" Value="3" GroupName="size-sm" />
<DRating Value="3" GroupName="size-md" />
<DRating Size="DaisySize.Large" Value="3" GroupName="size-lg" />Clearable— The invisible area left of the first glyph resets the value to 0
Value: 4
<DRating Clearable="true" @bind-Value="_clearable" GroupName="demo-clear" />
<span class="badge badge-lg badge-ghost">Value: @_clearable</span>
@code {
private double _clearable = 4;
}Half stars— Half="true" doubles the radios (mask-half-1 / mask-half-2) so @bind-Value supports 0.5 steps
Value: 3.5
Value: 2.5
<DRating Half="true" @bind-Value="_half" GroupName="demo-half" />
<span class="badge badge-lg badge-success">Value: @_half.ToString("0.0")</span>
<DRating Half="true" Icon="DaisyRatingIcon.Heart" Max="3" Clearable="true" @bind-Value="_halfHearts" GroupName="demo-half-hearts" />
<span class="badge badge-lg badge-error">Value: @_halfHearts.ToString("0.0")</span>
@code {
private double _half = 3.5;
private double _halfHearts = 2.5;
}Disabled
<DRating Value="4" Disabled="true" GroupName="demo-disabled" />Tips
- Each instance auto-generates a unique radio
name ; setGroupName for stable prerender/hydration or shared native form posts. - Set
Value without@bind-Value for a read-only display. - Colors follow
currentColor — wrap in atext-warning -styled container to recolor glyphs. Value is adouble : whole stars withoutHalf , half steps with it (daisy splits each star into two half-width masked radios).
API
DRating
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Max | int | 5 | — | Number of items in the rating (default 5; values below 1 are clamped). |
| Icon | DaisyRatingIcon | Star | — | Glyph for each item (star or heart — daisyUI mask utilities). StarHeart |
| Size | DaisySize | Medium | — | Sizes the glyphs (rating-xs ... rating-lg). ExtraSmallSmallMediumLargeExtraLarge |
| Clearable | bool | False | — | Adds a leading invisible hit area that resets the rating to 0. |
| Half | bool | False | — | Half-value ratings: each star becomes two hit halves ( rating-half + mask-half-1/2 ), so Value can be e.g. 3.5. |
| Disabled | bool | False | — | Disables all items. |
| GroupName | string | — | — | HTML radio group name. Auto-generated per instance when not set — set it explicitly when several ratings share one native form post, or to keep prerender/hydration stable. |
| Class | string | — | — | — |
| Style | string | — | — | — |
| Value | double | 0 | @bind-Value | — |
| ValueExpression | Expression<Func<double>> | — | — | — |
| DisplayName | string | — | — | — |