GitHub

slider

Styled range input with label, hint, and a CSS-driven fill gradient that tracks the thumb live as you drag.

Basic

slider({ name: 'volume', label: 'Volume', showValue: true })

Min, max, step, and hint

Adjust display brightness (0–200)

slider({
  name:      'brightness',
  label:     'Brightness',
  min:       0,
  max:       200,
  step:      10,
  value:     100,
  showValue: true,
  hint:      'Adjust display brightness (0–200)',
})

Live value in state

Use data-event="change:mutationName" to capture the value when the user releases the handle. The fill gradient always updates live — no mutation needed for that.

// state
{ brightness: 100 }

// mutation
setBrightness: (state, e) => ({ brightness: Number(e.target.value) })

// view
slider({
  name:      'brightness',
  label:     'Brightness',
  min:       0,
  max:       200,
  step:      10,
  value:     state.brightness,
  showValue: true,
  event:     'change:setBrightness',
})

Disabled

slider({ name: 'opacity', label: 'Opacity', value: 30, disabled: true })
The fill gradient updates live during drag automatically. To read the final value, either use data-event="change:mutationName" on the slider or submit it as part of a form — the value is available in FormData as a number string under name.
Do not use data-event="input:mutationName" on a slider. Pulse replaces innerHTML on every mutation, which interrupts the drag mid-gesture. Use change instead — it fires once when the user releases the handle.
PropTypeDefaultDescription
namestring—Field name — submitted in FormData
labelstring—Visible label text
minnumber0Minimum value
maxnumber100Maximum value
stepnumber1Step increment
valuenumber50Current value
showValuebooleanfalseShow current value live beside the label as you drag
disabledbooleanfalse
hintstring—Helper text below the slider
eventstring—data-event binding, e.g. change:mutationName
idstring—Override the generated id
classstring—