Skip to content

Forms

Slider

A range slider on a native input[type=range].

stableCSS onlyEnhancer: enhanceSliderBuilt on <input type="range">hydrateless/slider.css

A range slider styled with the hl-slider primitive. It is a native <input type="range">, so keyboard support, step increments, and form values all come built in. No JavaScript. Wrap it in data-hl-slider with an <output> and the optional enhancer keeps the readout, aria-valuetext, and the filled track in sync.

Playground

Live

With a live readout

The enhancer writes the formatted value to the <output> and to aria-valuetext on every change, and publishes --hl-slider-progress so the track fills up to the thumb in every engine. data-hl-unit adds a suffix without any script.

Live
35%

JavaScript

This component ships an optional enhancer. With auto-init it loads automatically; to wire it yourself, import it directly:

import { enhanceSlider } from '@hydrateless/enhancers/slider';

const handle = enhanceSlider(document);
// handle.api  -> imperative controls
// handle.destroy()  -> tear everything down

Props

The framework bindings expose these props (and forward the rest to the root element).

PropTypeDefaultDescription
minnumber0Minimum value.
maxnumber100Maximum value.
valuenumberNot setControlled value; pair with the native `onChange` in React (Vue: `v-model`, Svelte: `bind:value`).

Events and callbacks

Event / CallbackPayloadDescription
hl:change{ value: number }Fires from an enhanced slider with the numeric value on every `input` (also the `onValueChange` callback).

CSS variables

Override these on any ancestor to theme the component. See the theme studio to preview changes live.

CSS variableUsed for
--hl-primaryFilled track and thumb color.
--hl-surface-3Empty track color.

Accessibility

  • A native range input exposes value, min, max, and step to assistive tech.
  • Arrow keys, Home, End, and Page Up/Down all adjust the value natively.
  • With the enhancer, aria-valuetext carries the formatted value and unit so "35%" is announced instead of "35".

Released under the MIT License.