Progressive enhancement of one or two native
<input type="range">
elements via
wf-slider.js
. Draws a custom track, fill highlight, optional tick marks, step labels, and per-thumb tooltips. Supports single-value and dual-thumb range modes. The native inputs stay in the DOM so form submission works with zero changes.
Quick Start
Wrap a single
<input type="range">
in a
div.wf-slider
with
data-wf-slider
. All elements matching that attribute are enhanced automatically on
DOMContentLoaded
. The
min
,
max
,
step
, and
value
attributes on the native input are fully respected.
Add
data-wf-range
and include two
<input type="range">
elements. The first controls the lower bound, the second the upper bound. The component prevents the thumbs from crossing – the lower thumb can never exceed the upper and vice versa.
Add
data-wf-ticks
to render tick marks at each step position. Labels are automatically shown alongside ticks; suppress them with
data-wf-labels="false"
. Use
data-wf-labels
alone (without
data-wf-ticks
) to show only text labels. Ticks and labels require a positive
step
attribute on the input and at most 100 steps.
Add
data-wf-tooltip
to show a floating bubble above the active thumb while dragging or on keyboard focus. The tooltip displays the current value including any unit suffix set via
data-wf-unit
. In range mode each thumb gets its own tooltip.
HTML
<!-- Single with tooltip -->
<div class="wf-slider" data-wf-slider data-wf-tooltip data-wf-unit="%">
<input type="range" min="0" max="100" value="65">
</div>
<!-- Range with per-thumb tooltips -->
<div class="wf-slider" data-wf-slider data-wf-range data-wf-tooltip data-wf-unit="px">
<input type="range" min="0" max="500" value="100">
<input type="range" min="0" max="500" value="380">
</div>
Unit Suffix
Set
data-wf-unit
to append a string after every value readout – tooltips, tick labels, and any external display element bound to
wf:slider-change
. Any string is accepted: %, px, °C, km/h, etc.
Set
data-wf-size
to
sm
or
lg
for smaller or larger track and thumb. The default is medium. A disabled slider applies
data-wf-disabled
to the wrapper – either in the HTML or through the native
disabled
attribute on the input.