Skip to content
GitHub11 stars

An input where the user selects a value from within a given range.

<Slider Value="75" Max="100" Step="1" aria-label="Volume" Class="mx-auto w-full max-w-xs" />

Installation

dnx Blazix.Cli add slider

Usage

<Slider Value="33" Max="100" Step="1" />

Range

Use an array with two values for a range slider.

<Slider Values="@([25, 50])" Max="100" Step="5" GetAriaLabel="@(i => i == 0 ? "Minimum price" : "Maximum price")" Class="mx-auto w-full max-w-xs" />

Multiple Thumbs

Use an array with multiple values for multiple thumbs.

<Slider Values="@([10, 20, 70])" Max="100" Step="10" GetAriaLabel="@(i => $"Value {i + 1}")" Class="mx-auto w-full max-w-xs" />

Vertical

Use orientation="vertical" for a vertical slider.

<div class="mx-auto flex w-full max-w-xs items-center justify-center gap-6">
    <Slider Value="50" Max="100" Step="1" Orientation="Orientation.Vertical" aria-label="Volume" Class="h-40" />
    <Slider Value="25" Max="100" Step="1" Orientation="Orientation.Vertical" aria-label="Brightness" Class="h-40" />
</div>

Controlled

0.3, 0.7
<div class="mx-auto grid w-full max-w-xs gap-3">
    <div class="flex items-center justify-between gap-2">
        <Label for="slider-demo-temperature">Temperature</Label>

Disabled

Use the Disabled parameter to disable the slider.

<Slider Value="50" Max="100" Step="1" Disabled="true" aria-label="Volume" Class="mx-auto w-full max-w-xs" />

RTL

To enable RTL support in Blazix, see the RTL configuration guide.

Translated with AI for the demo, so it may have mistakes.

// The preview sets dir and lang around this example, as your app sets them on <html>. // It uses components added with "rtl": true. See the RTL guide.

<Slider Value="75" Max="100" Step="1" aria-label="@Texts[Language]" Class="mx-auto w-full max-w-xs" />

@code {
    [CascadingParameter] private Language Language { get; set; } = Language.Arabic;

    private static readonly Translations<string> Texts = new(En: "Volume", Ar: "مستوى الصوت", He: "עוצמת קול");
}

API Reference

Slider

ParameterTypeDefault
Value double? -
Format string? -
Name string? -
ReadOnly bool false
Disabled bool false
Orientation Orientation Orientation.Horizontal
MinStepsBetweenValues int 0
LargeStep double 10
Step double 1
Max double 100
Min double 0
OnValueCommitted EventCallback<IReadOnlyList<double>> -
OnValueChange EventCallback<ValueChangeEventArgs<IReadOnlyList<double>>> -
ValuesChanged EventCallback<IReadOnlyList<double>?> -
Values IReadOnlyList<double>? -
ValueChanged EventCallback<double> -
GetAriaLabel Func<int, string>? -
Class string? -

Other attributes are passed to the element it renders.