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
In the package npm i hellskitchen-ui Import hk-slider and use it directly.

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
valuenumber0Single-thumb value. Two-way bindable.
rangeHkSliderRange | nullnullTwo-thumb value ([number, number]). Takes over from value when set. Two-way bindable.
min / maxnumber0 / 100Bounds.
stepnumber1Increment for pointer and keyboard.
ticksbooleanfalseDraws a mark at each step.
labelstring''Shown above the track and used as the accessible name (prefixed "Minimum" / "Maximum" per thumb in range mode).
suffixstring''Unit appended to the displayed value.

Outputs

  • valueChange / rangeChangeEventEmitter<number> / EventEmitter<HkSliderRange | null>

    Emits while dragging.

  • committedEventEmitter<number | HkSliderRange>

    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.

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