DeepWorks Studios Blazor Component Library

Demo user Administrator ยท Blazor Server Library 20261206222504-6e8ff32.dirty

DwsRating

API Reference

Read-only

Readonly shows the value but ignores input; it stays focusable for assistive technology. A value set from code is not snapped to the step, so a read-only rating can show an average such as 3.7.

Average 3.7
Show Code
Rating.razor

<DwsRating Name="RatingDemo_Readonly" Label="Average 3.7" SelectedValue="3.7" Readonly="true" />

Disabled

Disabled greys the rating out, ignores input and takes it out of the tab order.

Disabled
Show Code
Rating.razor

<DwsRating Name="RatingDemo_Disabled" Label="Disabled" SelectedValue="2" Disabled="true" />

Tooltips

GetTooltip returns the tooltip of each icon; Tooltip covers the whole rating.

Difficulty
Show Code
Rating.razor

<DwsRating Name="RatingDemo_GetTooltip" Label="Difficulty" SelectedValue="2" GetTooltip="@GetDifficultyTooltip" Tooltip="How hard was it?" />
Rating.razor.cs

private static string GetDifficultyTooltip(int item) => item == 1 ? "1 point: easy" : $"{item} points";

Selection mode

SelectionMode.Single fills only the icon holding the value instead of every icon up to it.

Single
Show Code
Rating.razor

<DwsRating Name="RatingDemo_Single" Label="Single" SelectionMode="DwsRatingSelectionMode.Single" SelectedValue="3"
           IconEmpty="@Icons.BS.EmojiNeutral" IconFilled="@Icons.BS.EmojiSmileFill" Color="DwsColor.Success" />

Colors

Color and EmptyColor go through the theme's CSS variables.

Show Code
Rating.razor

<DwsRating Name="RatingDemo_Color_Default" SelectedValue="3" />
<DwsRating Name="RatingDemo_Color_Primary" SelectedValue="3" Color="DwsColor.Primary" EmptyColor="DwsColor.Secondary" />
<DwsRating Name="RatingDemo_Color_Error" SelectedValue="3" Color="DwsColor.Error" IconEmpty="@Icons.BS.Heart" IconFilled="@Icons.BS.HeartFill" />

Sizes

Size sets the icon size.

XSmall
Small
Medium
Large
XLarge
Show Code
Rating.razor

@foreach (DwsSize size in Enum.GetValues<DwsSize>())
{
    <DwsRating Name="@($"RatingDemo_Size_{size}")" Label="@size.ToString()" SelectedValue="2" Size="size" />
}

Sizes per breakpoint

SizeSm, SizeMd, SizeLg and SizeXl override Size from 576px, 768px, 992px and 1200px up - resize the window to see the rating grow.

Responsive
Show Code
Rating.razor

<DwsRating Name="RatingDemo_Size_Responsive" Label="Responsive" SelectedValue="2"
           Size="DwsSize.XSmall" SizeMd="DwsSize.Medium" SizeXl="DwsSize.XLarge" />

Custom icons

IconEmpty and IconFilled accept any icon classes; the filled icon is clipped on top of the empty one, so half steps work with every icon set.

Show Code
Rating.razor

<DwsRating Name="RatingDemo_Icons_Battery" SelectedValue="3" IconEmpty="@Icons.BS.BatteryHalf" IconFilled="@Icons.BS.BatteryFull" Color="DwsColor.Success" />
<DwsRating Name="RatingDemo_Icons_Sun" SelectedValue="2.5" Step="0.5" IconEmpty="@Icons.BS.Sun" IconFilled="@Icons.BS.SunFill" Color="DwsColor.Warning" />

Vertical orientation

Vertical orientation stacks the icons bottom-up like a meter, so the Up arrow key raises the value on screen too.

Show Code
Rating.razor

<DwsRating Name="RatingDemo_Orientation_Vertical" SelectedValue="2" Orientation="DwsLayoutOrientation.Vertical" />

Interface-Description

Name Typ Parameters Description
ResetAsync Task Clears the rating to 0 and raises SelectedValueChanged / OnValueChanged as a user change would. Works on a read-only rating too.
Name Typ Default Description
SelectedValue double 0 The rating; 0 means not rated. Supports two-way binding via @bind-SelectedValue. A value set from code is clamped to 0..MaxValue but not snapped to Step, so a read-only rating can show 3.7. Setting it from code never raises SelectedValueChanged; with SelectedValueChanged bound the rating shows the value the parent passes back.
MaxValue int 5 Number of icons. Can change at any time; the shown value is clamped to the new range. Falls back to 5 when not positive.
Step double 1 Granularity of user input: 1 for whole icons, 0.5 for half icons, 2 for even values only. A step below 1 must divide 1 evenly (at most 10 parts per icon). Invalid steps fall back to 1.
SelectionMode DwsRatingSelectionMode DwsRatingSelectionMode.Continuous Continuous fills every icon up to the value; Single fills only the icon holding it.
AllowReset bool false Lets the user clear the rating by picking the current value again, or with Delete / Backspace.
Readonly bool false Shows the value but ignores user input. The rating stays focusable.
EnablePreview bool true Previews the value under the pointer before it is picked.
Label string string.Empty Caption rendered before the icons; it also names the rating for assistive technology (aria-labelledby).
ValueLabels IReadOnlyList<string>? null A label per whole value, index 0 for value 1. Shown next to the icons for the previewed or selected value, used as aria-valuetext, and as each icon's tooltip unless GetTooltip is set.
ShowValueLabel bool true Shows the ValueLabels entry of the current value next to the icons.
Tooltip string string.Empty Tooltip for the whole rating.
GetTooltip Func<int, string?>? null Returns the tooltip of the icon at the given 1-based position; null or empty shows none.
TooltipPosition DwsTooltipPosition DwsTooltipPosition.Top Kept so existing markup still compiles: the tooltip is the browser's native title, which has no position.
IconEmpty string "bi bi-star" Icon classes of an empty icon.
IconFilled string "bi bi-star-fill" Icon classes of a filled icon. It is clipped on top of the empty icon, so partial values work with any icon set.
Color DwsColor DwsColor.RatingStar Color of the filled icons, resolved through the theme's CSS variables.
EmptyColor DwsColor DwsColor.Undefined Color of the empty icons. Undefined uses Color.
ValueColors IReadOnlyList<DwsColor>? null A color per whole value, index 0 for value 1; applied according to ColorMode. Values beyond the list use its last entry. Overrides Color for filled icons.
ColorMode DwsRatingColorMode DwsRatingColorMode.Value Value: every filled icon takes the color of the current value. Star: each icon keeps its own color, forming a gradient.
Size DwsSize DwsSize.Medium Icon size on the smallest screens, and on every screen without a breakpoint size.
SizeSm DwsSize? null Icon size from 576px up. Unset keeps the next smaller size.
SizeMd DwsSize? null Icon size from 768px up. Unset keeps the next smaller size.
SizeLg DwsSize? null Icon size from 992px up. Unset keeps the next smaller size.
SizeXl DwsSize? null Icon size from 1200px up. Unset keeps the next smaller size.
Orientation DwsLayoutOrientation DwsLayoutOrientation.Horizontal Lays the icons out in a row, or in a column that fills bottom-up like a meter so the Up arrow key raises the value on screen too.
SelectedValueExpression Expression<Func<double>>? null The bound field, set by @bind-SelectedValue. Under static SSR the rating is one radio per icon named after it (Model.Stars), posting whole steps.
Name Typ Description
SelectedValueChanged EventCallback<double> Raised with the requested value when the user changes the rating. Used by @bind-SelectedValue.
OnValueChanged EventCallback<double> Raised after every user change with the requested value. Stays available when @bind-SelectedValue is used.
HoveredValueChanged EventCallback<double?> Raised while the pointer previews a value, and with null once it leaves the icons.
OnMouseEnter EventCallback<MouseEventArgs> Raised when the pointer enters the rating.
OnMouseLeave EventCallback<MouseEventArgs> Raised when the pointer leaves the rating.
OnFocus EventCallback<FocusEventArgs> Raised when the rating receives focus.
OnBlur EventCallback<FocusEventArgs> Raised when the rating loses focus.
Name Typ Default Description
Element ElementReference The associated web component. May be null if accessed before the component is rendered.
ComponentGuid Guid Unique identifier for the component.
TypeString string The name of the component type, obtained from reflection.
Authorized_RegisterEnabled bool false Indicates whether this component is enabled through a permission registry.
Authorized_RegisterSelected bool false Indicates whether this component is selected in permission selection mode.
GetInitializedState bool false Returns whether the component is initialized.
GetRenderModeState DwsRenderMode Returns the current render mode.
GetComponentState DwsComponentStateType Returns the current component state.
GetIsInteractiveState bool false Returns whether the component is interactive.
GetIsPrerenderingState bool false Returns whether the component is prerendering.
GetComponentLoadingState bool false Returns whether the component is loading.
IsFormBusy bool false Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState).
Name Typ Parameters Description
DebugInfo void Logs debug information about the component.
UpdateState void Updates the component's state and triggers StateHasChanged.
UpdateStateAsync Task Asynchronously updates the component's state and triggers StateHasChanged.
Dispose void Disposes the component and releases resources.
FocusAsync ValueTask bool containedInScrollableList Sets focus to the component's element.
Name Typ Default Description
Name string Required unique identifier for the component within its container.
Visible bool true Determines if the component is visible in the UI.
Disabled bool false Disables the form control, ensuring it doesn't participate in form submission.
ComponentNameSpace string The namespace for permission-based access control.
PermissionKey string? null A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins.
Class string Optional CSS class names.
Style string Optional in-line styles.
Tag object An optional user-defined object to store any additional data with the component.
BackReference DwsReference A reference to the enclosing component.
ID string The HTML ID attribute for the component.
AdditionalAttributes Dictionary<string, object> Additional HTML attributes for the component's root element.
IgnorePermissionChecks bool false Bypasses all permission checks for this component.
IgnorePermissionSelection bool false Ignore permission selection mode for this component.
IgnoreFormBusy bool false Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it.
Name Typ Description
OnInitializedCallbackStarted EventCallback Callback when OnInitialized starts.
OnInitializedCallback EventCallback Callback during OnInitialized.
OnInitializedCallbackCompleted EventCallback Callback when OnInitialized completes.
OnInitializedAsyncCallbackStarted EventCallback Callback when OnInitializedAsync starts.
OnInitializedAsyncCallback EventCallback Callback during OnInitializedAsync.
OnInitializedAsyncCallbackCompleted EventCallback Callback when OnInitializedAsync completes.
OnIsComponentLoadingChanged EventCallback<bool> Callback when IsComponentLoading changes.
OnCurrentRenderModeChanged EventCallback<DwsRenderMode> Callback when CurrentRenderMode changes.
OnComponentStateChanged EventCallback<DwsComponentStateType> Callback when ComponentState changes.
An error has occurred. This app may no longer respond until reloaded.