Skip to content
Form Slider

Slider

A native range input for one value, or two thumbs for a range.

On this page

Examples

Single and range

Volume: 40, range: 100 to 300

Razor
<div class="flex w-full max-w-sm flex-col gap-6">
    <KlyFormField Label="Volume">
        <KlySlider @bind-Value="_volume" Min="0" Max="100" Step="5" />
    </KlyFormField>
    <KlyFormField Label="Price range">
        <KlyRangeSlider @bind-Value="_range" Min="0" Max="500" Step="10" Color="KlyColor.Neutral" />
    </KlyFormField>
    <p class="text-sm text-(--klyroo-text-muted)" data-testid="slider-state">Volume: @_volume, range: @_range[0] to @_range[1]</p>
</div>

@code {
    private double _volume = 40;
    private IReadOnlyList<double> _range = [100, 300];
}

Bound to int and float

KlySlider<TNumber> takes any built-in numeric type; Min, Max and Step stay doubles.

Volume: 40, gain: 1

Razor
<div class="flex w-full max-w-sm flex-col gap-6">
    <KlyFormField Label="Volume (int)">
        <KlySlider @bind-Value="_volume" Min="0" Max="100" Step="5" />
    </KlyFormField>
    <KlyFormField Label="Gain (float)">
        <KlySlider @bind-Value="_gain" Min="0" Max="2" Step="0.1" />
    </KlyFormField>
    <p class="text-sm text-(--klyroo-text-muted)" data-testid="typed-slider-state">Volume: @_volume, gain: @_gain.ToString(System.Globalization.CultureInfo.InvariantCulture)</p>
</div>

@code {
    private int _volume = 40;
    private float _gain = 1.0f;
}

API

KlySlider<TNumber>

Slider with one thumb, bound to a number of any built-in numeric type ( double , int , decimal , float ...) or its nullable form. A nullable slider with no value rests on its minimum; moving it sets a value.

Parameters

Name Type Default Description
AriaLabel string Accessible name 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.
Immediate bool false Report every move to .NET instead of the final value. Costs a round trip per step in Server mode.
Max Double 100 Largest value of the track. Defaults to 100.
Min Double 0 Smallest value of the track. Defaults to 0.
Name string Form field name outside an EditForm . Inside one, the name comes from the bound expression.
Orientation KlyOrientation KlyOrientation.Horizontal Direction of the layout: Horizontal or Vertical . Values: Horizontal, Vertical.
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.
Step Double 1 Distance between two values the thumb can take. Defaults to 1.
Ui SliderUi Per-instance class overrides of the slots of the slider, see SliderUi . They are merged after the theme and the Class parameter wins on the root slot.
Value (@bind-Value) TNumber 0 The value of the control. Bind it with @bind-Value .
ValueExpression Expression<Func<TNumber>> 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 SliderUi with one class string per slot, merged after the theme.

Slot Styles
Root Classes merged into the root slot of KlyRangeSlider and KlySlider`1 , after the theme and the app configuration.
Track Classes merged into the track slot of KlyRangeSlider and KlySlider`1 , after the theme and the app configuration.
Range Classes merged into the range slot of KlyRangeSlider and KlySlider`1 , after the theme and the app configuration.
Thumb Classes merged into the thumb slot of KlyRangeSlider and KlySlider`1 , after the theme and the app configuration.

KlyRangeSlider

Slider with two thumbs that binds to a list of two numbers.

Parameters

Name Type Default Description
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.
Immediate bool false Report every move to .NET instead of the final values. Costs a round trip per step in Server mode.
Max Double 100 Largest value of the track. Defaults to 100.
Min Double 0 Smallest value of the track. Defaults to 0.
Name string Form field name outside an EditForm . Inside one, the name comes from the bound expression.
Orientation KlyOrientation KlyOrientation.Horizontal Direction of the layout: Horizontal or Vertical . Values: Horizontal, Vertical.
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.
Step Double 1 Distance between two values the thumbs can take. Defaults to 1.
Ui SliderUi Per-instance class overrides of the slots of the range slider, see SliderUi . They are merged after the theme and the Class parameter wins on the root slot.
Value (@bind-Value) IReadOnlyList<Double> The value of the control. Bind it with @bind-Value .
ValueExpression Expression<Func<IReadOnlyList<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 SliderUi with one class string per slot, merged after the theme.

Slot Styles
Root Classes merged into the root slot of KlyRangeSlider and KlySlider`1 , after the theme and the app configuration.
Track Classes merged into the track slot of KlyRangeSlider and KlySlider`1 , after the theme and the app configuration.
Range Classes merged into the range slot of KlyRangeSlider and KlySlider`1 , after the theme and the app configuration.
Thumb Classes merged into the thumb slot of KlyRangeSlider and KlySlider`1 , after the theme and the app configuration.