sterling-svelte  2.0.20
A modern, accessible, lightweight UI component library for Svelte.

RangeSlider

A range value set by dragging low and high thumbs between a minimum and maximum.

Code
<script lang="ts">
  import { RangeSlider } from '@geoffcox/sterling-svelte';

  let lowValue = $state(0);
  let highValue = $state(0);
</script>

<RangeSlider bind:lowValue bind:highValue/>

Members

Property NameTypeBindableDefaultComment
disabledboolean | null | undefinednofalseWhen true, the slider is disabled.
highValuenumber | undefinedno0The high value of the range.
lowValuenumber | undefinedno0The low value of the range.
maxnumber | undefinedno100The maximum value of the slider.
minnumber | undefinedno0The minimum value of the slider.
onChange(value: { low?: number, high?: number}) => voidnoundefinedCalled when the low or high values of the slider changes.
precisionnumber | undefinednoundefinedThe number of decimal places to round the values.
reverseboolean | null | undefinednofalseWhen true, the slider direction from min to max is reversed.
stepnumber | undefinedno1The amount the value changes by pressing arrow keys.
verticalboolean | null | undefinednofalseWhen true, the slider is displayed vertically.

Considerations

  • Includes HTMLDivElement props, events, and methods.
  • When a thumb is the equivalent of :active, the thumb element will have the 'active' class.
  • When a thumb is being dragged, the thumb element will have the 'dragging' class.
  • When a thumb can be moved by keyboard input, the thumb element will have the 'keyboard-focus' class.

Anatomy

<div class="sterling-range-slider>
  <div class="container">
    <div class="track"></div>
    <div class="fill"></div>
    <div class="thumb low"></div>
    <div class="thumb high"></div>
  </div>
</div>