DeepWorks Studios Blazor Component Library

Demo user Administrator ยท Blazor Server Library 20261206222504-6e8ff32.dirty

DwsSlider

API Reference

Common patterns

Reference

Sizes and lengths

Size scales track and thumb in one go. Horizontally the slider takes the full width of its container; Width gives it a fixed length in px, yet it never spills out of a narrower container. From 576, 768, 992 and 1200px up, SizeSm, SizeMd, SizeLg and SizeXl take over the size.

XSmall
Small
Medium
Large
XLarge
Width 240px
XSmall on a phone, Medium from 768px, XLarge from 1200px
Show Code
Slider.razor

<div class="d-flex flex-column gap-3">
    @foreach (DwsSize size in Enum.GetValues<DwsSize>())
    {
        <DwsSlider Name="@($"SliderDemo_Size_{size}")" Size="size" Min="0" Max="100" @bind-Value="_sizeValue">@size</DwsSlider>
    }
    <DwsSlider Name="SliderDemo_Size_Width" Width="240" Min="0" Max="100" @bind-Value="_sizeValue">Width 240px</DwsSlider>
    <DwsSlider Name="SliderDemo_Size_Breakpoints" Size="DwsSize.XSmall" SizeMd="DwsSize.Medium" SizeXl="DwsSize.XLarge" Min="0" Max="100"
               @bind-Value="_sizeValue">XSmall on a phone, Medium from 768px, XLarge from 1200px</DwsSlider>
</div>
Slider.razor.cs

private int _sizeValue = 35;

Theme colours and your own look

Track, fill and thumb each take a theme colour: Color, ColorFilled and ThumbColor. TrackSize and ThumbSize set sizes in px, TrackClass and ThumbClass add classes. Gradients and shapes come from the custom properties --dws-slider-track, --dws-slider-fill, --dws-slider-thumb (each takes any background), --dws-slider-track-radius, --dws-slider-thumb-radius and --dws-slider-thumb-border, set here through Style.

Battery: success fill on a dark track
Risk: error fill, dark thumb
Heat: gradient fill, square thumb
Show Code
Slider.razor

<div class="d-flex flex-column gap-3" style="max-width: 480px;">
    <DwsSlider Name="SliderDemo_Color_Success" Color="DwsColor.Dark" ColorFilled="DwsColor.Success" Min="0" Max="100"
               @bind-Value="_colorValue">Battery: success fill on a dark track</DwsSlider>
    <DwsSlider Name="SliderDemo_Color_Error" Color="DwsColor.Secondary" ColorFilled="DwsColor.Error" ThumbColor="DwsColor.Dark" Min="0" Max="100"
               @bind-Value="_colorValue">Risk: error fill, dark thumb</DwsSlider>
    <DwsSlider Name="SliderDemo_Style_Gradient" TrackSize="10" ThumbSize="24" Min="0" Max="100" @bind-Value="_colorValue"
               Style="--dws-slider-fill: linear-gradient(90deg, var(--success), var(--warning), var(--error)); --dws-slider-thumb-radius: 6px; --dws-slider-thumb-border: 3px solid var(--text);">
        Heat: gradient fill, square thumb
    </DwsSlider>
</div>
Slider.razor.cs

private int _colorValue = 55;

Interface-Description

Name Typ Parameters Description
FocusEndAsync ValueTask Moves keyboard focus to the upper thumb of a range slider. The inherited FocusAsync focuses the lower (or only) thumb.
Name Typ Default Description
Min T 0 Lower end of the range. Falls back to 0..100 (logged once) when it is not below Max.
Max T 100 Upper end of the range.
Step T 1 Distance between the values a thumb can land on in Discrete mode. A step that is not positive or larger than the range falls back to 1 (a hundredth of a range below 1), logged once.
Value T default The value - with Range, the lower end of the selection. Two-way bindable via @bind-Value. A value from the parent is clamped to the range (and in Discrete mode drawn on the step grid) without raising ValueChanged.
RawValue string? null Value as an invariant ('.'-decimal) string, two-way bindable via @bind-RawValue. A ',' from the parent is read as the decimal separator; unreadable text raises CastingToValueFailed and leaves the value as it was.
Range bool false Shows a second thumb: Value and EndValue select a range. The thumbs cannot pass each other.
EndValue T 100 Upper end of the selection with Range, clamped to Max. Two-way bindable via @bind-EndValue.
Mode DwsSliderMode DwsSliderMode.Discrete Discrete lands on fixed steps; Continuous moves smoothly to any value and ignores Step (an integer T is still rounded).
Immediate bool true Raises the change callbacks on every movement. When false the slider still follows the pointer and updates its bubble, but raises them once when the thumb is released or a key changed it.
TickMarks bool false Draws tick marks on the track.
TickInterval double? null Distance between tick marks in value units, independent of Step. Unset uses the step (in Continuous mode ten equal parts). More than 101 marks fall back to ten equal parts (logged once).
SnapToTicks bool false Lets the thumbs land only on tick marks: the tick interval becomes the step, also in Continuous mode.
TickMarkLabels IReadOnlyList<string>? null A label per tick mark, index 0 for the lowest. Takes precedence over ShowTickLabels.
ShowTickLabels bool false Labels every tick mark with its value, formatted like the value bubble.
Marks IReadOnlyList<DwsSliderMark>? null Marks at any value of the range: DwsSliderMark(Value, Label = null, Tooltip = null). Replace the evenly spaced tick marks; TickMarks does not have to be on. A mark with a Tooltip shows it on hover and can be clicked. Marks outside Min..Max are left out.
ShowNumberField bool false Shows an editable number field below the rail, kept in step with the slider - two fields for a Range slider. The fields are dense DwsInputs (role="spinbutton", a decimal keyboard on a phone, 44px high on a touch screen). Typed values are read with the page culture's decimal separator; a number inside the range moves the thumb at once, and Enter or leaving the field clamps it to Min / Max and puts it on the Step grid. ArrowUp / ArrowDown step, PageUp / PageDown step by ten.
ChildContent RenderFragment? null Caption above the slider; it also names the slider for assistive technology.
ValueLabelMode DwsSliderValueLabelMode DwsSliderValueLabelMode.None When the value bubble shows: None, Auto (while a thumb is hovered, dragged or focused by keyboard) or Always.
Format string? null .NET format string for the bubble, tick labels and the announced value, in the current culture ("C", "P0", "0.0 'kg'"). An invalid one is ignored and logged once.
ValueFormatter Func<T, string>? null Returns the text shown and announced for a value; takes precedence over Format.
Color DwsColor DwsColor.Primary Color of the track.
ColorFilled DwsColor DwsColor.Accent Color of the filled part of the track.
ThumbColor DwsColor DwsColor.Undefined Color of the thumbs. Undefined uses ColorFilled.
Width int? null Length of a horizontal slider in px. Unset fills the container; it never overflows a narrower one.
Height int? null Height of a vertical slider in px, caption included. Unset, it fills a parent with a definite height (a sized box, a stretched flex item), shrinking or growing with it; elsewhere its track is 200px long.
TrackSize int? null Track thickness in px; overrides the thickness from Size.
ThumbSize int? null Thumb diameter in px; overrides the diameter from Size.
Size DwsSize DwsSize.Small Track and thumb size on the smallest screens, and on every screen without a breakpoint size.
SizeSm DwsSize? null Size from 576px up. Unset keeps the next smaller size.
SizeMd DwsSize? null Size from 768px up. Unset keeps the next smaller size.
SizeLg DwsSize? null Size from 992px up. Unset keeps the next smaller size.
SizeXl DwsSize? null Size from 1200px up. Unset keeps the next smaller size.
Orientation DwsLayoutOrientation DwsLayoutOrientation.Horizontal A vertical slider grows upwards, so the Up arrow key raises the value on screen too.
Inverted bool false Reverses the direction: Max on the left of a horizontal slider and at the bottom of a vertical one (normally on the right and at the top).
Animated bool true Animates thumbs, fill and bubble when the value changes by keyboard or from code; dragging follows the pointer directly. Off with prefers-reduced-motion.
TrackClass string? null Extra classes for the track and fill. See also --dws-slider-track, --dws-slider-fill (any background) and --dws-slider-track-radius.
ThumbClass string? null Extra classes for the thumbs. See also --dws-slider-thumb (any background), --dws-slider-thumb-radius and --dws-slider-thumb-border.
ValueExpression Expression<Func<T>>? null The bound field, set by @bind-Value. Names the (start) range input (Model.Volume) for a statically rendered form.
EndValueExpression Expression<Func<T>>? null The bound upper end of a Range, set by @bind-EndValue. Names the end input.
Name Typ Description
ValueChanged EventCallback<T> Raised when the user changes Value (the lower thumb of a range) - on every movement, or once per change with Immediate false.
RawValueChanged EventCallback<string> Raised together with ValueChanged, with the value as an invariant string.
EndValueChanged EventCallback<T> Raised when the user moves the upper thumb of a range slider.
CastingToValueFailed EventCallback Raised when a RawValue from the parent cannot be converted to T.
OnFocus EventCallback<FocusEventArgs> Raised when a thumb receives focus.
OnBlur EventCallback<FocusEventArgs> Raised when a thumb loses focus.
OnMarkClick EventCallback<DwsSliderMark> Raised when a mark with a Tooltip is clicked. Bound: the slider leaves the value alone. Unbound: the nearest thumb moves to the mark.
Name Typ Default Description
Element ElementReference The associated web component. May be null if accessed before the component is rendered.
ComponentGuid Guid Unique identifier for the component.
TypeString string The name of the component type, obtained from reflection.
Authorized_RegisterEnabled bool false Indicates whether this component is enabled through a permission registry.
Authorized_RegisterSelected bool false Indicates whether this component is selected in permission selection mode.
GetInitializedState bool false Returns whether the component is initialized.
GetRenderModeState DwsRenderMode Returns the current render mode.
GetComponentState DwsComponentStateType Returns the current component state.
GetIsInteractiveState bool false Returns whether the component is interactive.
GetIsPrerenderingState bool false Returns whether the component is prerendering.
GetComponentLoadingState bool false Returns whether the component is loading.
IsFormBusy bool false Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState).
Name Typ Parameters Description
DebugInfo void Logs debug information about the component.
UpdateState void Updates the component's state and triggers StateHasChanged.
UpdateStateAsync Task Asynchronously updates the component's state and triggers StateHasChanged.
Dispose void Disposes the component and releases resources.
FocusAsync ValueTask bool containedInScrollableList Sets focus to the component's element.
Name Typ Default Description
Name string Required unique identifier for the component within its container.
Visible bool true Determines if the component is visible in the UI.
Disabled bool false Disables the form control, ensuring it doesn't participate in form submission.
ComponentNameSpace string The namespace for permission-based access control.
PermissionKey string? null A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins.
Class string Optional CSS class names.
Style string Optional in-line styles.
Tag object An optional user-defined object to store any additional data with the component.
BackReference DwsReference A reference to the enclosing component.
ID string The HTML ID attribute for the component.
AdditionalAttributes Dictionary<string, object> Additional HTML attributes for the component's root element.
IgnorePermissionChecks bool false Bypasses all permission checks for this component.
IgnorePermissionSelection bool false Ignore permission selection mode for this component.
IgnoreFormBusy bool false Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it.
Name Typ Description
OnInitializedCallbackStarted EventCallback Callback when OnInitialized starts.
OnInitializedCallback EventCallback Callback during OnInitialized.
OnInitializedCallbackCompleted EventCallback Callback when OnInitialized completes.
OnInitializedAsyncCallbackStarted EventCallback Callback when OnInitializedAsync starts.
OnInitializedAsyncCallback EventCallback Callback during OnInitializedAsync.
OnInitializedAsyncCallbackCompleted EventCallback Callback when OnInitializedAsync completes.
OnIsComponentLoadingChanged EventCallback<bool> Callback when IsComponentLoading changes.
OnCurrentRenderModeChanged EventCallback<DwsRenderMode> Callback when CurrentRenderMode changes.
OnComponentStateChanged EventCallback<DwsComponentStateType> Callback when ComponentState changes.
An error has occurred. This app may no longer respond until reloaded.