Skip to content
GitHub11 stars

An easily stylable range input.

<SliderRoot Value="25">
    <SliderControl class="slider-control">
        <SliderTrack class="slider-track">
            <SliderIndicator class="slider-indicator" />
            <SliderThumb aria-label="Volume" class="slider-thumb" />
        </SliderTrack>
    </SliderControl>
</SliderRoot>

Usage guidelines

  • Form controls must have an accessible name: Prefer SliderLabel, or give each SliderThumb an aria-label when no visible label is rendered.

Anatomy

Import the primitives and assemble the parts:

@using Blazix.Primitives

<SliderRoot>
    <SliderLabel />
    <SliderValue />
    <SliderControl>
        <SliderTrack>
            <SliderIndicator />
            <SliderThumb />
        </SliderTrack>
    </SliderControl>
</SliderRoot>

API Reference

SliderRoot

Renders a <div> element.

ParameterTypeDefault
Value double? -
ValueChanged

Called with the new value when Value changes, for @bind-Value.

EventCallback<double> -
Values IReadOnlyList<double>? -
ValuesChanged

Called with the new value when Values changes, for @bind-Values.

EventCallback<IReadOnlyList<double>?> -
OnValueChange

Runs before the value changes, with the reason; call Cancel() to keep it.

EventCallback<ValueChangeEventArgs<IReadOnlyList<double>>> -
OnValueCommitted EventCallback<IReadOnlyList<double>> -
Min

The minimum value.

double 0
Max

The maximum value.

double 100
Step

The amount the value changes by with the arrow keys or the buttons.

double 1
LargeStep double 10
MinStepsBetweenValues int 0
Orientation

Which way the parts are laid out, and which arrow keys move between them.

Orientation Orientation.Horizontal
Disabled

Whether the component should ignore user interaction.

bool false
ReadOnly

Whether the user should be unable to change the value. It stays focusable.

bool false
Name string? -
Format string? -
Culture

The culture the value is formatted with.

CultureInfo? -
Render RenderFragment<SliderRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-dragging

Present while the user is dragging.

-
data-orientation

Indicates the orientation of the slider.

'horizontal' | 'vertical'
data-disabled

Present when the slider is disabled.

-
data-valid

Present when the slider is in a valid state (when wrapped in FieldRoot).

-
data-invalid

Present when the slider is in an invalid state (when wrapped in FieldRoot).

-
data-dirty

Present when the slider's value has changed (when wrapped in FieldRoot).

-
data-touched

Present when the slider has been touched (when wrapped in FieldRoot).

-
data-focused

Present when the slider is focused (when wrapped in FieldRoot).

-

SliderValue

Renders a <output> element.

ParameterTypeDefault
Render RenderFragment<SliderRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-dragging

Present while the user is dragging.

-
data-orientation

Indicates the orientation of the slider.

'horizontal' | 'vertical'
data-disabled

Present when the slider is disabled.

-
data-valid

Present when the slider is in a valid state (when wrapped in FieldRoot).

-
data-invalid

Present when the slider is in an invalid state (when wrapped in FieldRoot).

-
data-dirty

Present when the slider's value has changed (when wrapped in FieldRoot).

-
data-touched

Present when the slider has been touched (when wrapped in FieldRoot).

-
data-focused

Present when the slider is focused (when wrapped in FieldRoot).

-

SliderIndicator

Renders a <div> element.

ParameterTypeDefault
Render RenderFragment<SliderRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-dragging

Present while the user is dragging.

-
data-orientation

Indicates the orientation of the slider.

'horizontal' | 'vertical'
data-disabled

Present when the slider is disabled.

-
data-valid

Present when the slider is in a valid state (when wrapped in FieldRoot).

-
data-invalid

Present when the slider is in an invalid state (when wrapped in FieldRoot).

-
data-dirty

Present when the slider's value has changed (when wrapped in FieldRoot).

-
data-touched

Present when the slider has been touched (when wrapped in FieldRoot).

-
data-focused

Present when the slider is focused (when wrapped in FieldRoot).

-

SliderTrack

Renders a <div> element.

ParameterTypeDefault
Render RenderFragment<SliderRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-dragging

Present while the user is dragging.

-
data-orientation

Indicates the orientation of the slider.

'horizontal' | 'vertical'
data-disabled

Present when the slider is disabled.

-
data-valid

Present when the slider is in a valid state (when wrapped in FieldRoot).

-
data-invalid

Present when the slider is in an invalid state (when wrapped in FieldRoot).

-
data-dirty

Present when the slider's value has changed (when wrapped in FieldRoot).

-
data-touched

Present when the slider has been touched (when wrapped in FieldRoot).

-
data-focused

Present when the slider is focused (when wrapped in FieldRoot).

-

SliderThumb

Renders a <div> element.

ParameterTypeDefault
Index int? -
AriaLabel string? -
GetAriaValueText Func<string, double, string>? -
Render RenderFragment<SliderThumbRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-dragging

Present while the user is dragging.

-
data-orientation

Indicates the orientation of the slider.

'horizontal' | 'vertical'
data-disabled

Present when the slider is disabled.

-
data-valid

Present when the slider is in a valid state (when wrapped in FieldRoot).

-
data-invalid

Present when the slider is in an invalid state (when wrapped in FieldRoot).

-
data-dirty

Present when the slider's value has changed (when wrapped in FieldRoot).

-
data-touched

Present when the slider has been touched (when wrapped in FieldRoot).

-
data-focused

Present when the slider is focused (when wrapped in FieldRoot).

-
data-index

Indicates the index of the thumb in range sliders.

-

SliderControl

Renders a <div> element.

ParameterTypeDefault
Render RenderFragment<SliderRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-dragging

Present while the user is dragging.

-
data-orientation

Indicates the orientation of the slider.

'horizontal' | 'vertical'
data-disabled

Present when the slider is disabled.

-
data-valid

Present when the slider is in a valid state (when wrapped in FieldRoot).

-
data-invalid

Present when the slider is in an invalid state (when wrapped in FieldRoot).

-
data-dirty

Present when the slider's value has changed (when wrapped in FieldRoot).

-
data-touched

Present when the slider has been touched (when wrapped in FieldRoot).

-
data-focused

Present when the slider is focused (when wrapped in FieldRoot).

-

SliderLabel

Renders a <label> element.

ParameterTypeDefault
Render RenderFragment<SliderRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.