Skip to content
Form InputRating

InputRating

A star rating built on radio buttons, with an optional half step and a read-only display.

On this page

Examples

Rating

Rating: 2

Razor
<div class="flex flex-col items-start gap-4">
    <KlyFormField Label="Your rating">
        <KlyInputRating @bind-Value="_rating" />
    </KlyFormField>
    <KlyFormField Label="With halves">
        <KlyInputRating AllowHalf Value="3.5" Color="KlyColor.Warning" />
    </KlyFormField>
    <KlyInputRating ReadOnly Value="4" AriaLabel="Average rating" Size="KlySize.Sm" />
    <p class="text-sm text-(--klyroo-text-muted)" data-testid="rating-state">Rating: @_rating</p>
</div>

@code {
    private double _rating = 2;
}

API

KlyInputRating

Star rating input, bindable to a double , with half steps and a read-only mode.

Parameters

Name Type Default Description
AllowHalf bool false Lets a star be chosen by halves (0.5, 1, 1.5…).
AriaLabel string Accessible name of the group when no KlyFormField label is around.
Class string Classes added to the root element, merged last so they win over the theme.
Color KlyColor "primary" Semantic color of the control: a built-in KlyColor or the name of a color you defined. When not set, Color applies, else primary. Values: primary, secondary, success, info, warning, error, neutral.
Disabled bool false Disables the control: it cannot be focused or changed and is not submitted.
Id string The id of the native control. Defaults to the one of the enclosing KlyFormField , else a generated one.
Max int 5 Number of stars. The value goes from 0 (nothing chosen) to this.
Name string Form field name outside an EditForm . Inside one, the name comes from the bound expression.
ReadOnly bool false Shows the value without letting it change. Rendered as an image with a text alternative, still posting the value.
Required bool false Marks the control as required, for the browser and for assistive technology.
Size KlySize? Defaults to the size of the enclosing KlyFormField , or medium. Values: Xs, Sm, Md, Lg, Xl.
Ui InputRatingUi Per-instance class overrides of the slots of the input rating, see InputRatingUi . They are merged after the theme and the Class parameter wins on the root slot.
Value (@bind-Value) Double 0 The value of the control. Bind it with @bind-Value .
ValueExpression Expression<Func<Double>> The expression of the bound field. The compiler sets it with @bind-Value , and validation uses it to find the field.

Ui slots

Ui takes a InputRatingUi with one class string per slot, merged after the theme.

Slot Styles
Root Classes merged into the root slot of KlyInputRating , after the theme and the app configuration.
Input Classes merged into the input slot of KlyInputRating , after the theme and the app configuration.
Star Classes merged into the star slot of KlyInputRating , after the theme and the app configuration.
Icon Classes merged into the icon slot of KlyInputRating , after the theme and the app configuration.
Fill Classes merged into the fill slot of KlyInputRating , after the theme and the app configuration.
FilledIcon Classes merged into the filledIcon slot of KlyInputRating , after the theme and the app configuration.