Slider

stable 2.8 kB
<hk-slider>

One thumb or two. In range mode the thumbs clamp against each other rather than swapping, which is what makes a range feel solid instead of glitchy.

#range#number

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
valuenumber0Single-thumb value. Two-way bindable.
range[number, number] | nullnullTwo-thumb value. Takes over from value when set.
min / maxnumber0 / 100Bounds.
stepnumber1Increment for pointer and keyboard.
ticksbooleanfalseDraws a mark at each step.
suffixstring''Unit appended to the displayed value.

Outputs

  • valueChange / rangeChangeEventEmitter<…>

    Emits while dragging.

  • committedEventEmitter<…>

    Emits once on release — use this to persist.

Keyboard

  • ← / ↓ Decrease by one step
  • → / ↑ Increase by one step
  • Page Up / Page Down Move by ten steps
  • Home / End Jump to min / max

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-slider-trackrgb(15 23 42 / 0.10)Unfilled track.
--hk-slider-filllinear-gradient(90deg, #dc2626, #991b1b)Filled portion.
--hk-slider-thumb#ffffffThumb colour.

Accessibility

  • Each thumb is a slider role with aria-valuenow, aria-valuemin and aria-valuemax kept current.
  • In range mode each thumb gets its own accessible name, so "minimum" and "maximum" are distinguishable.
  • Thumbs clamp rather than swap, so the value under the pointer never jumps to the other end.

More in Forms