# Blazor Slider and Range Slider

URL: https://flexcoreui.com/demo/sliders  
Section: Components  
Controls: SliderControl, RangeSliderControl  
Keywords: slider, range slider, range input

Blazor sliders for picking a number or a range by dragging, with Min, Max and Step, reporting the value while it moves.

## Documentation

### Slider

| Name | Type | Default | Description |
|---|---|---|---|
| Value | double | 0 | Current number. Two-way with @bind-Value. |
| Min / Max | double | 0 / 100 | Bounds, written to the input's min and max. |
| Step | double | 1 | Increment for dragging and the arrow keys. |
| ShowValue | bool | true | Renders the raw Value after the track. No format option; hide it to format your own. |
| Disabled | bool | false | Disables the input and dims the host. The base Enabled is not read by this control. |
| CssClass / Style (base) | string? | null | On the host element. The base Visible is not applied; hide the host yourself. |
| Id / Title / Tag / Data / Parent (base) |  | null | Accepted but not rendered. A written id binds to Id, so it does not reach the input. |
| (unmatched attributes) | Dictionary<string,object> |  | Written on the <input>, such as aria-label, aria-valuetext, name and data-*. |

### Range

| Name | Type | Default | Description |
|---|---|---|---|
| Value | NumericRange | (25, 75) | Start and end. Two-way with @bind-Value. Must lie inside Min..Max with Start <= End, or the control throws ArgumentException on render. |
| ValueExpression | Expression<Func<NumericRange>>? | null | Set by @bind-Value inside an EditForm; the field is marked changed on the cascaded EditContext. |
| Min / Max | double | 0 / 100 | Bounds for both thumbs. Min must be below Max. |
| Step | double | 1 | Increment; values snap to the nearest step from Min. Must be positive. |
| ReadOnly | bool | false | Disables both inner sliders without the read-only look of a text box. |
| ShowValue | bool | true | Renders Start – End in an <output> under the sliders. |
| Format | string | "0.##" | Numeric format for the readout, current culture. |
| StartLabel / EndLabel | string | "Range start" / "Range end" | Visible label and aria-label of the lower and upper slider. |
| AriaLabel | string | "Range" | Accessible name of the group. |
| Enabled (base) | bool | true | false disables both sliders. |
| Visible (base) | bool | true | false hides the group with display:none. |
| CssClass / Style (base) | string? | null | On the group element. |
| Id / Title / Tag / Data / Parent (base) · unmatched attributes |  | null | Accepted but not rendered. |

### Events

| Name | Type | Description |
|---|---|---|
| SliderControl.ValueChanged | double | On every input event while dragging, and again on change at release. |
| RangeSliderControl.ValueChanged | NumericRange | After either slider moves the range, with the whole range; not raised when the snapped range is unchanged. |

### Range type

| Name | Type | Description |
|---|---|---|
| Start | double | Lower bound. |
| End | double | Upper bound. |
| ctor |  | new(start, end); a positional record with value equality, so an unchanged range does not raise ValueChanged. |

### Methods

| Name | Type | Description |
|---|---|---|
| RangeSliderControl.SetValueAsync(range) | Task | Sets both bounds at once, raises ValueChanged and notifies the EditContext. Ignored when disabled, read-only or unchanged; throws ArgumentOutOfRangeException outside Min..Max. |

### Css

| Name | Description |
|---|---|
| fx-slider-host · .fx-slider-disabled | Inline flex row, full width, 120px minimum; disabled adds opacity 0.5 and pointer-events: none. |
| fx-slider-range | The input: 6px track, 18px round thumb that scales on hover. |
| fx-slider-value | The readout: bold, right-aligned, 32px minimum width. |
| fx-range-slider | Grid of two labeled rows (95px label column) and the <output> readout; 220px minimum width. |

### Keys

| Name | Description |
|---|---|
| Arrow Right / Arrow Up | Increase by one Step. |
| Arrow Left / Arrow Down | Decrease by one Step. |
| Home / End | Jump to Min / Max. |
| Page Up / Page Down | Larger jump; the size is chosen by the browser. |

## Examples

### Slider

```razor
@using Fx.ControlKit

<div class="sl">
    <div class="field">
        <span class="field-label">Surcharge</span>
        <SliderControl @bind-Value="_surcharge" Min="0" Max="50" Step="0.5" ShowValue="false" aria-label="Fuel surcharge percent" />
        <span class="readout">@_surcharge.ToString("0.#")%</span>
    </div>
    <div class="field">
        <span class="field-label">Pallets</span>
        <SliderControl @bind-Value="_pallets" Min="1" Max="8" aria-label="Pallets" />
    </div>
    <div class="field">
        <span class="field-label">Tax rate %</span>
        <SliderControl Value="8.25" Min="0" Max="20" Step="0.25" Disabled="true" aria-label="Tax rate, fixed" />
    </div>
    <p class="result" role="status">SHP-0456 by road freight: base rate @BaseRate.ToString("$#,##0") + @_surcharge.ToString("0.#")% fuel surcharge = <strong>@Total.ToString("$#,##0")</strong>, or <strong>@((Total / _pallets).ToString("$#,##0"))</strong> per pallet</p>
</div>
```

```csharp
// Slider
private double _surcharge = 12.5, _pallets = 2;
private double BaseRate => 240 * _pallets;
private double Total => BaseRate * (1 + _surcharge / 100);
```

