Skip to content

Slider โ€‹

A slider with any number of thumbs, from Basecoat's range look. One number gives one thumb, and an array gives one thumb per entry: [20, 80] is a range, [2, 2, 3] is three thumbs. It also has a vertical type, discrete stops, a minimum gap between thumbs, tick marks with labels, track gaps, a value bubble per thumb, and form binding. Toggle Vue / CSS to switch the live demo and source together.

The look is the same as <mono-input type="range"> under every flavor, because both read the same --mono-input-range-* design knobs. Under ONE it follows the EJI guide's slider: a 4px track, a 16px navy thumb with a white rim, and the value at the end of the label row in bold navy mono figures. The guide's single slider has no fill, but a range needs its span on screen, so the slider fills with the accent.

ts
import '@mono-lit/helper/ui/slider'          // <mono-slider>
import '@mono-lit/helper/ui/shadow/slider'   // <mono-shadow-slider> (SSR / shadow DOM)

Basic โ€‹

Vue SFC

Range โ€‹

An array gives one thumb per entry. The span between the first and last thumb fills. Pressing on that span and dragging moves both thumbs together, keeping their distance. A plain click on the track moves the nearest thumb there. Thumbs block each other, so value[0] โ‰ค value[1] โ‰ค โ€ฆ always holds.

Vue SFC

Multiple thumbs โ€‹

Any length works. Thumbs may share a value. To pull a stack apart, drag up to take the top thumb, or down to take the bottom one. With the keyboard, Arrow Up/Right on a stacked thumb hands over to the top of the stack.

Vue SFC

Vertical โ€‹

type="vertical" runs the track from min at the bottom to max at the top. height sets the track length (default 200px). Mark labels sit beside the track and the value bubble to its left.

Vue SFC

Min gap โ€‹

min-gap is the smallest distance kept between neighbouring thumbs. A dragged thumb stops that far from its neighbour. A value handed over too tight is spread to fit, and thumbs that cannot all fit are packed against the ends.

Vue SFC

Stops โ€‹

stops lists the only values a thumb can land on, however unevenly they are spaced. It replaces step. The keyboard walks the list, and PageUp/PageDown jump a tenth of it. marks with no value puts a tick on every stop.

Vue SFC

Marks โ€‹

  • marks (or marks="true") puts a tick at every step. On a grid denser than 26 ticks, only the two ends get one.
  • A list such as [0, 50, { value: 100, label: 'Max' }] puts a tick, with a label under it, at each value. A mark without its own label shows the formatted value.
  • Ticks inside the filled span switch to the active colour.
Vue SFC

Track gap โ€‹

track-gap cuts this many px of track away around each thumb, like Material 3's slider. Each stretch then becomes its own rounded bar.

Vue SFC

Fill โ€‹

fill="auto" (the default) fills from min to the thumb with one thumb, and between the thumbs with several. With three or more thumbs, every inner stretch fills. start fills from min to the first thumb, end from the last thumb to max, and none fills nothing.

Vue SFC

Value tooltip โ€‹

value-tooltip controls the bubble on each thumb. auto (the default) shows it on hover, keyboard focus and while dragging. always shows it permanently and reserves room above the track for it. never turns it off. This is separate from tooltip, which is the label โ“˜ as on every other form control.

Vue SFC

Formatting โ€‹

format-display and format-locale work as on mono-input. They shape the label-row readout, the bubbles, the mark labels and aria-valuetext, never the value. Use "{}%", '"Rp "#,##0' with format-locale="id-ID", or a function: :format-display.prop="({ value }) => โ€ฆ". value-separator (default " โ€“ ") joins the values in the readout. show-value="false" hides the readout.

Vue SFC

Sizes โ€‹

size scales the track and thumb from the flavor's own geometry, so every style keeps a full xs to xxl ladder.

Vue SFC

Colors โ€‹

Vue SFC

States โ€‹

  • disabled fades the slider and takes it out of the tab order.
  • readonly keeps the thumbs focusable but never moves them.
  • required shows the asterisk and sets aria-required.
  • validation-state / validation-message (or error-message, success-message) recolour the slider and show the message.
Vue SFC

Form โ€‹

Bind with :control-form="form" and key-form, like any form control. The form owns the value, a number or an array, and renders the validation. A rule's value is the slider's model as is, so a custom rule can read value[1] - value[0]. Note that the built-in min / max rules measure an array by its length, not its numbers.

With a name, the element also writes one hidden <input> per thumb, so a native <form> submits it: name for one thumb, name[] repeated for several.

Vue SFC

Events โ€‹

input fires while dragging and on every key press. change fires on release and after each key. Both carry { modelValue, value, oldValue, values, index }. values is always an array, and index is the thumb that moved, or -1 when a segment drag moved two thumbs. The mno-input / mno-change aliases fire too.

Vue SFC

Keyboard โ€‹

KeyAction
Arrow Right / UpOne step up (Right is down in RTL)
Arrow Left / DownOne step down
Page Up / Page DownTen steps (or a tenth of the stops)
Home / EndTo this thumb's own lowest / highest place (its neighbours ยฑ min-gap)

Each thumb is a role="slider" with its own aria-valuemin/max, which are its neighbours' bounds, plus aria-valuenow, aria-valuetext and aria-orientation. With two thumbs they are named "(minimum)" and "(maximum)".

CSS Variables โ€‹

Vue SFC

Every look value first reads a --mono-slider-* knob, then the matching --mono-input-range-* knob, then vega's value. The flavors write the input-range knobs, so the slider follows every flavor with no entries of its own. Set the --mono-slider-* knob to restyle only sliders.

VariableDefaultControls
--mono-slider-accent--primary (set by color / a validation state)Fill and thumb colour
--mono-slider-track-height / -track-radius / -track-bg / -fill0.375rem / full / --muted / the accentThe track and its filled stretches
--mono-slider-thumb-size / -thumb-width / -thumb-radius / -thumb-bg1rem / = size / full / whiteThe thumb (border-box)
--mono-slider-thumb-border-width / -border-color / -ring-width / -ring-color / -shadow1px / the accent / 0 / โ€“ / --mono-shadow-smRim, resting ring and shadow
--mono-slider-ring-width / -hover-ring-width / -ring-color / -ring-alpha4px / = ring width / --ring / --mono-ring-alphaFocus / hover halo
--mono-slider-height / -gap / -length1.25rem / --mono-input-gap / 200pxControl box, label โ†” track spacing, vertical track length
--mono-slider-label-color / -font-size / -line-height / -font-weightthe input label'sLabel
--mono-slider-value-color / -font-family / -font-size / -font-weight / -min-width--muted-foreground / inherit / the label's / medium / 3chReadout
--mono-slider-mark-size / -mark-color / -mark-active-colormax(4px, half the track) / muted / --primary-foregroundTicks
--mono-slider-mark-label-font-size / -line-height / -color / -gap--mono-text-xs / 1rem / muted / 1.5 ร— spacingMark labels
--mono-slider-tooltip-bg / -color / -radius / -font-family / -font-size / -offset--foreground / --background / --mono-radius-md / inherit / xs / 2 ร— spacingValue bubble

Types โ€‹

Importimport { SliderProps } from '@mono-lit/helper'
PropValueDefaultDescription
modelValuestring | number | number[]โ€”The value: a number for one thumb, an array for several (`[20, 80]` is a range, `[2, 2, 3]` is three thumbs). The shape you pass is the shape you get back. A JSON string is accepted.
valuestring | number | number[]โ€”The same as `modelValue`.
minstring | numberโ€”Lowest value. Default 0.
maxstring | numberโ€”Highest value. Default 100.
stepstring | numberโ€”Snap interval. Default 1; `0` slides continuously. Ignored when `stops` is set.
stopsstring | number[]โ€”Discrete snap points: the thumb can only land on these values (`[0, 10, 25, 50, 100]`). Replaces `step`. A JSON string is accepted.
minGapstring | numberโ€”Smallest distance kept between neighbouring thumbs. Default 0 (thumbs may stack).
type'horizontal' | 'vertical'โ€”`vertical` runs the track bottom (min) to top (max). Give it a `height`.
marksstring | SliderMark[] | booleanโ€”Tick marks: `true` for one at every step (or every stop), or a list of values / `{ value, label }`. Labels render under the track (beside it when vertical), drawn through `format-display` when a mark has no label of its own. A JSON string is accepted.
fill'none' | 'auto' | 'start' | 'end'โ€”What the coloured part of the track covers. Default `auto`.
trackGapstring | numberโ€”Empty space cut out of the track around each thumb, in px (Material 3 style). Default 0.
valueTooltip'auto' | 'always' | 'never'โ€”When each thumb shows its value bubble. Default `auto` (hover, focus or drag).
showValuebooleanโ€”Show the value at the end of the label row. Default `true`; `show-value="false"` hides it.
valueSeparatorstringโ€”Joins the values in the label-row readout. Default `" โ€“ "`.
formatDisplaystring | (ctx: InputFormatCtx) => stringโ€”How a value is DISPLAYED (readout, bubbles, mark labels, `aria-valuetext`): a pattern (`"{}%"`, `'"Rp "#,##0'`) or a function `({ value }) => string`. The model stays a number.
formatLocalestringโ€”Locale a numeric `format-display` pattern is drawn with.
size'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'โ€”Visual size: scales the track, thumb and type.
color'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'teal' | 'purple' | 'neutral' | 'dark'โ€”Accent colour of the fill and thumb.
labelstringโ€”Label text above the slider.
helperTextstringโ€”Helper text under the slider.
tooltipstring | MonoTooltipOptionsโ€”Info icon at the end of the label; hovering, focusing or tapping it shows this text. Plain text โ†’ a small built-in bubble (no dependency). Full tooltip options (`:tooltip.prop="{ content, placement, color }"`) โ†’ a `mono-tooltip`, which needs the optional `@floating-ui/dom` + `@floating-ui/core` peers (without them that form renders no icon). Shown only beside a label. This is NOT the thumb's value bubble โ€” that is `value-tooltip`.
validationState'warning' | 'default' | 'invalid' | 'valid'โ€”โ€”
validationMessagestringโ€”โ€”
errorbooleanโ€”โ€”
errorMessagestringโ€”โ€”
successbooleanโ€”โ€”
successMessagestringโ€”โ€”
disabledbooleanโ€”Disables interaction and dims the slider.
readonlybooleanโ€”Focusable, but the value cannot be changed.
requiredbooleanโ€”Marks the field required (asterisk + `aria-required`).
namestringโ€”Form field name. The element writes one hidden `<input>` per thumb, so a native `<form>` submits it (`name` for one thumb, `name[]` repeated for several).
ariaLabelTextstringโ€”Accessible label (each thumb adds "minimum" / "maximum" / its position).
ariaLabelstringโ€”โ€”
heightstring | numberโ€”Track length when vertical (CSS length or px number). Default 200px.
widthstring | numberโ€”Width of the whole field (CSS length or px number).
cssClassSliderCssClassโ€”Per-part class overrides for internal elements.
visiblebooleanโ€”Whether the control is shown. Defaults to `true`.
visibleType'none' | 'invisible'โ€”How it hides when `visible` is `false`. Defaults to `'none'`.