Inputs
Slider
BitSlider turns a number into a distance you can point at: drag the thumb, press the rail to send it there, or step it with the keyboard. A second thumb turns it into a range, with distances to keep the two apart, an option to stop them crossing or to let one push the other, and a band to slide the whole range by. The fill can grow from either end or from an origin of your own, or be dropped altogether; marks can be drawn, labelled, and made the only values the user may land on; and a floating label can ride along with the thumb. It runs horizontally or vertically, in three sizes and any theme color, and - because it is built on native range inputs - touch dragging, form posting, EditForm validation and the whole slider keyboard come with it.
Usage
Every example is live. Open its code to see exactly what produced the component running underneath.
Basic
Range
Marks
Vertical
Fill, origin & inversion
Thumb label
Range constraints
Draggable band
Value display
Binding
Events
Validation
Accessibility
Cascading parameters
Color
Size
Style & Class
:root or any ancestor re-skins every slider below it while one on
Style re-skins that instance alone, and anything left unset falls back to the theme token beside
it - which is how a reshaped slider still follows the Material or Cupertino preset.
RTL
CSS variables
The public custom properties this component reads off its root, for what no parameter covers.
Every variable is read with a fallback and never declared by the component, so it inherits like any other custom property:
set one on :root (or in a [bit-theme] block) to restyle every instance, on any ancestor to restyle the ones inside it,
or on the Style of one instance to restyle that one alone. Leave a variable unset and the component falls back to the theme token beside it.
BitSlider CSS variables
| Name | Default value | Description |
|---|---|---|
| --bit-Slider-color | The Color role's main color | The accent: the filled part of the track and the ring around every thumb. |
| --bit-Slider-hover-color | --bit-Slider-color when set, otherwise the Color role's hover color | The accent while the slider is hovered (pointer devices only). |
| --bit-Slider-active-color | --bit-Slider-color when set, otherwise the Color role's active color | The accent while a thumb - or the draggable band - is held down, which is the feedback a pointer drag gets in place of the focus ring a keyboard gets. |
| --bit-Slider-focus-color | --bit-Slider-color when set, otherwise the Color role's focus color | The ring around the thumb that holds the keyboard focus. A slider whose value is invalid ignores it and takes --bit-Slider-invalid-color (the error focus color by default) instead. |
| --bit-Slider-disabled-color | --bit-clr-bg-dis | The fill, the thumb ring, the marks and the origin tick while Disabled is true. |
| --bit-Slider-invalid-color | --bit-clr-err | The fill, the thumb ring and the focus ring while the value is invalid. The focus ring falls back to the error focus color rather than to --bit-clr-err. |
| --bit-Slider-rail-color | --bit-clr-bg-sec | The part of the track the fill has not reached, which stays neutral whichever Color is picked. |
| --bit-Slider-rail-size | --bit-siz-track-sm / -md / -lg, per Size | Thickness of the rail and of the fill. |
| --bit-Slider-rail-radius | The rail thickness | Corner radius of the rail and of the fill. The default rounds them into a pill; set it to 0 for a square-ended bar. |
| --bit-Slider-thumb-size | --bit-siz-slider-thumb-sm / -md / -lg, per Size | Diameter of a thumb. It is also the width a vertical slider lays its track inside, and the room kept clear at each end of the track for the thumb to travel into. |
| --bit-Slider-thumb-radius | --bit-shp-radius-full | Corner radius of a thumb. |
| --bit-Slider-thumb-border-width | --bit-shp-brd-width-thick | Thickness of the accent ring around a thumb. |
| --bit-Slider-thumb-background | --bit-clr-bg-pri | The face of a thumb, inside its ring. A page background is what keeps a thumb a distinguishable shape where it overlaps the fill. |
| --bit-Slider-thumb-shadow | none | Elevation of a thumb. It is also what a thumb falls back to when it gives the focus ring up, since the ring and the shadow are the same property. |
| --bit-Slider-length | 9rem / 12rem / 15rem, per Size | Length of a vertical slider, which has none of its own to inherit from the line it sits on. It has no effect on a horizontal one, which fills its container. |
| --bit-Slider-gap | 0.5rem | Room between the track and the value labels beside it. |
| --bit-Slider-font-size | Per Size, from the type ramp | Size of the caption and of the value labels. |
| --bit-Slider-font-weight | --bit-tpg-field-label-font-weight (caption), --bit-tpg-fw-semibold (value labels) | Weight of the caption and of the value labels. |
| --bit-Slider-letter-spacing | --bit-tpg-ctrl-letter-spacing | Tracking of the caption and of the value labels. |
| --bit-Slider-label-color | --bit-clr-fg-pri | Color of the caption above the slider. |
| --bit-Slider-value-color | --bit-clr-fg-pri | Color of the value labels beside the track. |
| --bit-Slider-required-color | --bit-clr-req | The asterisk drawn after the caption of a required slider. |
| --bit-Slider-mark-size | The rail thickness, floored at 2px | Diameter of a mark tick. The floor is what keeps the marks of a hairline rail visible. |
| --bit-Slider-mark-color | --bit-clr-fg-ter | A mark the fill has not reached. |
| --bit-Slider-mark-active-color | The Color role's on-color | A mark the fill has reached, drawn on top of it in the contrasting color so it stays legible there. |
| --bit-Slider-mark-label-color | --bit-clr-fg-sec | The text written under a mark. |
| --bit-Slider-mark-label-font-size | Per Size, one ramp step below the value labels | Size of that text. |
| --bit-Slider-mark-label-height | 1.5em of that text | Height of the row the mark labels stand in under a horizontal track. The labels are taken out of the flow, so the row is what reserves the space under the track for them - a MarkLabelTemplate taller than a line of text has to be given the room here. An upright slider measures its own row against the length of the track. |
| --bit-Slider-thumb-label-color | The Color role's on-color | Text of the floating label that rides along with a thumb. |
| --bit-Slider-thumb-label-background | The accent color | Background of that label. |
| --bit-Slider-thumb-label-radius | --bit-shp-radius-popup | Its corner radius. |
| --bit-Slider-thumb-label-padding | 0.125rem 0.375rem | Its padding. |
| --bit-Slider-thumb-label-font-size | As the mark labels | Its font size. |
| --bit-Slider-thumb-label-room | 2.75x the label's font size | The room held open above a horizontal slider for the floating label to rise into, so it never lands on the caption or on whatever else the page has put above the slider. Set it to 0 to take the room back and let the label overlap. An upright slider needs none: its label stands beside the track. |
| --bit-Slider-origin-color | --bit-clr-fg-sec | The tick marking where the fill grows out of, drawn by Origin and IsOriginFromZero. |
| --bit-Slider-origin-width | --bit-shp-brd-width-thick | Thickness of that tick. |
| --bit-Slider-transition-duration | --bit-mot-duration-short | How long the fill and the thumbs take to follow a value that arrives in one jump - a key, a press on the rail, a change made elsewhere on the page. A thumb held under the pointer is never eased, whatever this is set to. |
API
Every parameter, public member, sub-class and enum this component exposes.
BitSlider parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AriaDescription | string? | null | A description of the Slider for the benefit of screen readers, beyond the name its label already gives it. It is rendered into a visually hidden element that every thumb references through its aria-describedby attribute, so it is announced after the name and the value rather than becoming part of the name. |
| AriaValueText | Func<double, string>? | null | A text description of the Slider number value for the benefit of screen readers. This should be used when the Slider number value is not accurately represented by a number. The returned text becomes the aria-valuetext of every thumb. |
| AutoFocus | bool | false | If true, the slider automatically receives focus when the page renders. |
| Classes | BitSliderClassStyles? | null | Custom CSS classes for different parts of the BitSlider. |
| Color | BitColor? | null | The general color of the slider, applied to the filled part of the track and to the thumbs. |
| DefaultLowerValue | double? | null | The default lower value of the ranged Slider, used when LowerValue is not bound. |
| DefaultUpperValue | double? | null | The default upper value of the ranged Slider, used when UpperValue is not bound. |
| DefaultValue | double | 0 | The default value of the Slider, used when Value is not bound. |
| DraggableTrack | bool | false | Lets the filled band between the two thumbs of a ranged Slider be dragged bodily, so the whole range travels at once and keeps the width it had. Only the rail strictly between the thumbs takes the drag, so the thumbs themselves stay grabbable. |
| GetValueText | Func<double, string>? | null | Builds the text of every label the Slider draws from the value it stands for. Takes precedence over ValueFormat, and is what AriaValueText falls back to. |
| Inverted | bool | false | Fills the track from the far end instead of from the near one. A ranged slider inverts into the two outer segments, leaving the span between the thumbs unfilled. |
| IsOriginFromZero | bool | false | Attaches the origin of the filled part of the track to zero. Shorthand for setting Origin to 0. |
| IsRanged | bool | false | If ranged is true, display two thumbs that allow the lower and upper bounds of a range to be selected. |
| IsVertical | bool | false | Whether to render the slider vertically. Its length comes from the --bit-Slider-length CSS variable, which defaults to 12rem. |
| Label | string? | null | Description label of the Slider, which also names it for assistive technologies when no AriaLabel is given. |
| LabelTemplate | RenderFragment? | null | Replaces the plain text Label of the Slider with custom content. |
| LargeStep | double? | null | The distance the larger keyboard jumps cover: Page Up and Page Down, and an arrow key held with Shift. It defaults to whatever the browser does on its own. |
| LowerAriaLabel | string? | null | The accessible name of the lower thumb of a ranged slider. |
| LowerValue | double | 0 | The lower value of the ranged Slider. |
| Marks | IEnumerable<BitSliderMark>? | null | The marks drawn along the track of the Slider, each optionally carrying a label. Takes precedence over ShowMarks. |
| MarkLabelTemplate | RenderFragment<BitSliderMark>? | null | Replaces the text under every mark with content of your own, built from the mark it belongs to. Setting it also asks for the marks. |
| MarkStep | double? | null | The interval between the generated marks, which setting is enough to ask for them. Defaults to the Step. |
| MaxRange | double? | null | The largest distance the two thumbs of a ranged slider are allowed to be apart. |
| MinRange | double | 0 | The smallest distance the two thumbs of a ranged slider are allowed to be apart. Any value above zero also stops the thumbs from crossing. |
| Min | double | 0 | The min value of the Slider. |
| Max | double | 10 | The max value of the Slider. |
| Name | string? | null | The name of the underlying range input, which is what makes the value readable by a plain form post. |
| NoFill | bool | false | Leaves the track unfilled, so the slider is a bare rail with a thumb on it rather than a bar that grows. It also turns off the highlighting of the marks the fill would otherwise have reached. |
| NoSwap | bool | false | Stops the two thumbs of a ranged slider from crossing over each other. |
| OnChange | EventCallback<double> | Callback when the value of a single-value Slider changes. This is called on every individual step. | |
| OnChangeEnd | EventCallback<double> | Callback for when the interaction that changes the value ends, rather than on every step along the way. | |
| OnFocusIn | EventCallback<FocusEventArgs> | Callback for when a thumb of the Slider receives the focus. | |
| OnFocusOut | EventCallback<FocusEventArgs> | Callback for when a thumb of the Slider loses the focus. | |
| OnRangeChange | EventCallback<BitSliderRangeValue> | Callback when the range of a ranged Slider changes. This is called on every individual step. | |
| OnRangeChangeEnd | EventCallback<BitSliderRangeValue> | Callback for when the interaction that changes the range ends, rather than on every step along the way. | |
| Origin | double? | null | The value the filled part of the track grows out of, instead of the near end of the track. Has no effect on a ranged slider. |
| Pushable | bool | false | Lets a thumb of a ranged slider push the other one along instead of stopping against it. It has nothing to do without a MinRange to keep or a NoSwap ordering to hold, and it keeps the thumbs on their own sides since pushing and crossing are opposites. |
| RangeValue | BitSliderRangeValue? | null | The range value of the Slider. Use this parameter to get or set both the LowerValue and the UpperValue at once. |
| ReadOnly | bool | false | Makes the Slider read-only: still focusable and announced, but refusing every change. |
| Required | bool | false | Marks the Slider as required, which is announced through aria-required. |
| RestrictToMarks | bool | false | Restricts the values the user can pick to the marks alone, so the thumb jumps from one mark to the next instead of moving by the Step in between them. |
| ShowMarks | bool | false | Draws a mark at every MarkStep (or every Step when that is not set) along the track. Setting MarkStep or ShowMarkLabels asks for the same series without it. |
| ShowMarkLabels | bool | false | Writes each mark's own value underneath it, which also asks for the marks. A mark handed to Marks with a label of its own keeps that label. |
| ShowValue | bool | true | Whether to show the value beside the Slider. |
| Size | BitSize? | null | Size of the Slider, which scales its track, thumbs and labels together. |
| SliderBoxHtmlAttributes | Dictionary<string, object>? | null | Additional html attributes for the Slider box, the element the track and the inputs are laid inside of. |
| Step | double | 1 | The difference between the two adjacent values of the Slider. Values of zero or below fall back to 1. |
| Styles | BitSliderClassStyles? | null | Custom CSS styles for different parts of the BitSlider. |
| ThumbLabel | BitSliderThumbLabel? | null | Decides when the floating label that rides along with the thumb is shown. |
| ThumbLabelTemplate | RenderFragment<double>? | null | Replaces the text of the floating label that rides along with the thumb with custom content, built from the value that thumb stands for. |
| UpperAriaLabel | string? | null | The accessible name of the upper thumb of a ranged slider. |
| UpperValue | double | 0 | The upper value of the ranged Slider. |
| Value | double | 0 | The value of the Slider. |
| ValueFormat | string? | null | Custom format for the displayed value of the Slider, applied to the value labels, the mark labels and the floating thumb labels alike. |
BitComponentBase parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AriaLabel | string? | null | Gets or sets the accessible label for the component, used by assistive technologies. |
| Class | string? | null | Gets or sets the CSS class name(s) to apply to the rendered element. |
| Dir | BitDir? | null | Gets or sets the text directionality for the component's content. |
| Disabled | bool | false | Gets or sets a value indicating whether the component is disabled and cannot respond to user interaction. |
| ForceAnimation | bool | false | Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested. |
| HtmlAttributes | Dictionary<string, object> | new Dictionary<string, object>() | Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. |
| Id | string? | null | Gets or sets the unique identifier for the component's root element. |
| Style | string? | null | Gets or sets the CSS style string to apply to the rendered element. |
| TabIndex | string? | null | Gets or sets the tab order index for the component when navigating with the keyboard. |
| Visibility | BitVisibility | BitVisibility.Visible | Gets or sets the visibility state (visible, hidden, or collapsed) of the component. |
BitComponentBase public members
| Name | Type | Default value | Description |
|---|---|---|---|
| UniqueId | Guid | Guid.NewGuid() | Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed. |
| RootElement | ElementReference | Gets the reference to the root HTML element associated with this component. |
BitSliderClassStyles properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Root | string? | null | Custom CSS classes/styles for the BitSlider's root element. |
| Label | string? | null | Custom CSS classes/styles for the BitSlider's label. |
| Container | string? | null | Custom CSS classes/styles for the BitSlider's container. |
| SliderBox | string? | null | Custom CSS classes/styles for the BitSlider's box, the element the track and the inputs are laid inside of. |
| Track | string? | null | Custom CSS classes/styles for the BitSlider's track, the full-length rail the thumb travels along. |
| Fill | string? | null | Custom CSS classes/styles for the BitSlider's fill, the highlighted part of the track. |
| Thumb | string? | null | Custom CSS classes/styles for the BitSlider's thumbs, the handles that travel along the track. |
| LowerThumb | string? | null | Custom CSS classes/styles for the lower thumb of a ranged BitSlider, added on top of Thumb. |
| UpperThumb | string? | null | Custom CSS classes/styles for the upper thumb of a ranged BitSlider, added on top of Thumb. |
| LowerValueInput | string? | null | Custom CSS classes/styles for the BitSlider's lower value input. |
| UpperValueInput | string? | null | Custom CSS classes/styles for the BitSlider's upper value input. |
| ValueInput | string? | null | Custom CSS classes/styles for the BitSlider's value input. |
| TrackInput | string? | null | Custom CSS classes/styles for the input that makes the filled band of a ranged BitSlider draggable, which is only rendered while DraggableTrack asks for it. |
| OriginFromZero | string? | null | Custom CSS classes/styles for the BitSlider's origin tick. |
| ValueLabel | string? | null | Custom CSS classes/styles for the BitSlider's value label. |
| LowerValueLabel | string? | null | Custom CSS classes/styles for the BitSlider's lower value label. |
| UpperValueLabel | string? | null | Custom CSS classes/styles for the BitSlider's upper value label. |
| Mark | string? | null | Custom CSS classes/styles for the BitSlider's mark ticks. |
| MarkLabel | string? | null | Custom CSS classes/styles for the BitSlider's mark labels. |
| ThumbLabel | string? | null | Custom CSS classes/styles for the BitSlider's floating thumb labels. |
BitSliderRangeValue properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Lower | double | 0 | The lower value of the ranged Slider. |
| Upper | double | 0 | The upper value of the ranged Slider. |
| Length | double | 0 | The distance between the two ends of the range. |
BitSliderMark properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Value | double | 0 | The value the mark sits at. A mark outside the Min..Max range of the slider is not rendered. |
| Label | string? | null | The text rendered under the mark. A mark without one is drawn as a plain tick, unless ShowMarkLabels is on - which labels it with its own value - or a MarkLabelTemplate is supplying the content. |
| Class | string? | null | Custom CSS classes for this mark, added to both its tick and its label. |
| Style | string? | null | Custom CSS styles for this mark, added to both its tick and its label. |
BitSliderThumbLabel enum
| Name | Value | Description |
|---|---|---|
| Off | 0 | Never show the floating label. |
| Auto | 1 | Show the floating label only while the slider is being hovered, dragged or focused. |
| On | 2 | Always show the floating label. |
BitSize enum
| Name | Value | Description |
|---|---|---|
| Small | 0 | The small size. |
| Medium | 1 | The medium size. |
| Large | 2 | The large size. |
BitColor enum
| Name | Value | Description |
|---|---|---|
| Primary | 0 | Primary general color. |
| Secondary | 1 | Secondary general color. |
| Tertiary | 2 | Tertiary general color. |
| Info | 3 | Info general color. |
| Success | 4 | Success general color. |
| Warning | 5 | Warning general color. |
| SevereWarning | 6 | SevereWarning general color. |
| Error | 7 | Error general color. |
| PrimaryBackground | 8 | Primary background color. |
| SecondaryBackground | 9 | Secondary background color. |
| TertiaryBackground | 10 | Tertiary background color. |
| PrimaryForeground | 11 | Primary foreground color. |
| SecondaryForeground | 12 | Secondary foreground color. |
| TertiaryForeground | 13 | Tertiary foreground color. |
| PrimaryBorder | 14 | Primary border color. |
| SecondaryBorder | 15 | Secondary border color. |
| TertiaryBorder | 16 | Tertiary border color. |
BitVisibility enum
| Name | Value | Description |
|---|---|---|
| Visible | 0 | The content of the component is visible. |
| Hidden | 1 | The content of the component is hidden, but the space it takes on the page remains (visibility:hidden). |
| Collapsed | 2 | The component is hidden (display:none). |
BitDir enum
| Name | Value | Description |
|---|---|---|
| Ltr | 0 | Ltr (left to right) is to be used for languages that are written from the left to the right (like English). |
| Rtl | 1 | Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic). |
| Auto | 2 | Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. |
Feedback
Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.