Slider
An input where the user selects a value from within a given range.
<NaviusSlider @bind-Value="_value" Min="0" Max="100" Step="1"
class="relative flex h-5 w-full items-center">
<NaviusSliderTrack class="relative h-1.5 w-full grow overflow-hidden rounded-full bg-muted">
<NaviusSliderRange class="bg-primary" />
</NaviusSliderTrack>
<NaviusSliderThumb class="block h-5 w-5 rounded-full border border-primary/60 bg-background
focus-visible:ring-2 focus-visible:ring-ring" />
</NaviusSlider>
@code { private IReadOnlyList<double> _value = new double[] { 60 }; }Features
- Can be controlled (
@bind-Value) or uncontrolled (DefaultValue). - Supports multiple thumbs: add more than one
NaviusSliderThumbfor a range. - Supports a custom
Step,Min/MaxandMinStepsBetweenThumbs. - Horizontal or vertical orientation, with optional
Inverteddirection and RTL support. - Full keyboard navigation; the thumb is
role="slider"with the correctaria-value*state. - Renders a hidden number input per thumb (when
Nameis set) for native form submission.
Installation
Install the brain, or copy just this primitive in with the CLI.
navius add sliderAnatomy
Import the parts and assemble them.
@using Navius.Primitives.Components.Slider
<NaviusSlider>
<NaviusSliderTrack>
<NaviusSliderRange />
</NaviusSliderTrack>
<NaviusSliderThumb />
</NaviusSlider>API Reference
Root
Contains all the parts of a slider. Owns the value array and cascades it to the parts. Renders a span.
| Prop | Type | Default |
|---|---|---|
| Value | IReadOnlyList<double>? | - |
| ValueChanged | EventCallback<IReadOnlyList<double>> | - |
| DefaultValue | IReadOnlyList<double>? | - |
| ValueCommitted | EventCallback<IReadOnlyList<double>> | - |
| Min | double | 0 |
| Max | double | 100 |
| Step | double | 1 |
| MinStepsBetweenThumbs | int | 0 |
| LargeStep | double | 0 |
| Orientation | string | "horizontal" |
| Inverted | bool | false |
| Dir | string? | - |
| Disabled | bool | false |
| Name | string? | - |
| Form | string? | - |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-orientation] | "horizontal" | "vertical" |
| [data-disabled] | Present when disabled |
Track
The rail the range fills and the thumb travels along. Renders a span.
| Prop | Type | Default |
|---|---|---|
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-orientation] | "horizontal" | "vertical" |
| [data-disabled] | Present when disabled |
Range
The filled portion of the track between the lowest and highest thumb. Renders a span (absolutely positioned).
| Prop | Type | Default |
|---|---|---|
| - | - | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-orientation] | "horizontal" | "vertical" |
| [data-disabled] | Present when disabled |
Thumb
A draggable handle and the accessibility surface (role=slider). Add one per value. Renders a span (absolutely positioned).
| Prop | Type | Default |
|---|---|---|
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-orientation] | "horizontal" | "vertical" |
| [data-disabled] | Present when disabled |
Accessibility
Adheres to the slider WAI-ARIA design pattern. Each thumb exposes aria-valuemin, aria-valuemax, aria-valuenow and aria-orientation; the bounds narrow to the neighbouring thumbs on a multi-thumb slider.
Keyboard interactions
| Key | Description |
|---|---|
| ArrowRight | Increments the value by Step (flips under RTL / Inverted). |
| ArrowLeft | Decrements the value by Step (flips under RTL / Inverted). |
| ArrowUp | Increments the value by Step. |
| ArrowDown | Decrements the value by Step. |
| Shift + Arrow | Increments / decrements by the large step. |
| PageUp | Increments the value by the large step. |
| PageDown | Decrements the value by the large step. |
| Home | Sets the value to Min. |
| End | Sets the value to Max. |