Skip to main content

Range

Slider input for selecting a value in a range.

Usage

<w-range value="50" min="0" max="100" label="Volume">
<w-slot rail>
<div>
<w-slot fill><div></div></w-slot>
<w-slot knob><div></div></w-slot>
</div>
</w-slot>
</w-range>

Props

PropTypeDefaultDescription
valuenumber0Current value
minnumber0Minimum value
maxnumber100Maximum value
stepnumber1Step increment
labelstring""Accessible label
disabledbooleanfalseDisable slider
orientation"horizontal" | "vertical""horizontal"Slider orientation

Slots

SlotElementDescription
trackContainerSlider track container
fillElementFilled portion of track
thumbElementDraggable thumb

Events

EventDetailDescription
change{ value }Value changed (on release)
input{ value }Value changing (while dragging)

Keyboard

KeyAction
ArrowRight / ArrowUpIncrement
ArrowLeft / ArrowDownDecrement
HomeSet to minimum
EndSet to maximum
PageUpIncrement by 10%
PageDownDecrement by 10%

Styling

The library positions the rail, fill, and knob automatically — you only style appearance. Position is fed via two custom properties on the host (--w-knob and --w-fill), updated on every value change.

/* Rail (the track) */
w-range w-slot[rail] > * {
background: #ddd;
border-radius: 2px;
}
w-range[orientation="horizontal"] w-slot[rail] > * {
height: 4px;
}
w-range[orientation="vertical"] w-slot[rail] > * {
width: 4px;
}

/* Fill */
w-range w-slot[fill] > * {
background: #6366f1;
border-radius: 2px;
}

/* Knob (thumb) */
w-range w-slot[knob] > * {
width: 20px;
height: 20px;
background: #6366f1;
border-radius: 50%;
cursor: pointer;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Disabled */
w-range[disabled] {
opacity: 0.5;
}
SelectorTargets
w-range[orientation="horizontal"]Horizontal slider (default)
w-range[orientation="vertical"]Vertical slider
w-range[disabled]Disabled state
--w-knobThumb position percentage (set by library)
--w-fillFill width/height percentage (set by library)

Accessibility

  • role="slider" with full ARIA value attributes
  • Keyboard accessible
  • Works with screen readers