You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP โ†’
Socket
Book a DemoInstallSign in
Socket

svelte-range-slider-pips

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-range-slider-pips

Multi-Thumb, Accessible, Beautiful Range Slider with Pips

4.0.7
latest
Source
npmnpm
Version published
Weekly downloads
9.9K
3.7%
Maintainers
1
Weekly downloads
ย 
Created
Source

Svelte Range Slider Logo

Svelte Range Slider v4

Code Version NPM version NPM Downloads / Month

A reactive, accessible, multi-thumb, range slider with the ability to display "pips" or "notches" along the range.
Importable as a svelte-component, or able to be used directly in any javascript application / framework.

Svelte Icon Vue Icon React Icon JS Icon JQUERY Icon

Svelte Range Slider; focussed with pips and labels prop set

๐Ÿ“”๐Ÿ”DocsFull Documentation & Examples
๐Ÿ“โš™REPLSvelte component demo
โคโœ’CodepenPlain JS component demo

Features

Features of the range slider plugin (written below)

  • โœจ fully customisable
  • โ™ฟ accessible
  • ๐Ÿ‘๐Ÿฝ multi-thumb
  • ๐ŸŽš ranges
  • ๐Ÿท floating labels
  • ๐Ÿ“ ruler values (pips)
  • ๐Ÿท labels for values
  • ๐Ÿงฎ step function
  • ๐Ÿ– formatter
  • ๐ŸŽญ animated
  • ๐Ÿ–‹ css variables

Install

Open your project and use the command line to install the package;

yarn add svelte-range-slider-pips --dev          # or
npm install svelte-range-slider-pips --save-dev  # if you prefer npm

Usage

Upgrading from v3 -> v4

Note: Please read the upgrade guide for details, as there's some changes which might break your styling/ui.

In a svelte 4 project

Assuming you have a Svelte app up and running;

<script>
  import RangeSlider from 'svelte-range-slider-pips';
</script>

<RangeSlider values={[50]} pips />

In a svelte 5 project

Svelte 5 works almost exactly the same as Svelte 4.

โš  Note: Runes Mode -- specifically $state() -- has some issues when binding with an <input /> element. My suggestion would be to use legacy mode if you can (not runes), or read this issue for a workaround.

In a svelte 3 project

โš  Version 3 of Range Slider Pips is not compatible with Svelte 3. see below

As a regular JS file

If you're not building a svelte-app, you can use the /dist/ version of the script /dist/svelte-range-slider-pips.js and include it with a regular <script> tag.
This should even work with jQuery.

<!-- in the <head> of your html -->
<script src="./js/vendor/svelte-range-slider-pips.js" />

<!-- in the <body> of your html -->
<div id="my-slider"></div>

<script>
  // this script will be run when the DOM is ready
  // and the slider is initialised
  document.addEventListener('DOMContentLoaded', () => {
    var mySlider = new RangeSliderPips({
      target: document.querySelector('#my-slider'),
      props: { values: [50], pips: true }
    });
  });
</script>

As a JS module, or with Vue & React

If you're building a bleeding-edge JS application (maybe Vue or React), you might want to use js imports (import)

import RangeSlider from './node_modules/svelte-range-slider-pips/dist/svelte-range-slider-pips.mjs';

var mySlider = new RangeSlider({
  target: node, // js reference to a DOM element
  props: { values: [50], pips: true }
});

Props (options)

Slider props

proptypedefaultdescription
valueNumber50Value to apply on the slider.
valuesArray[50]Array of values to apply on the slider. Multiple values creates multiple handles. (note: A slider with range property set can only have two values max)
minNumber0Minimum value for the slider (should be < max)
maxNumber100Maximum value for the slider (should be > min)
stepNumber1Every nth value to allow handle to stop at (should be a positive value)
rangeBoolean/StringfalseWhether to style as a range picker. Use range='min' or range='max' for min/max variants
pushyBooleanfalseIf range is true, then this boolean decides if one handle will push the other along
draggyBooleanfalseIf range is true, enables dragging the range area between handles
rangeGapMinNumber0If range is true, sets the minimum allowed distance between handles
rangeGapMaxNumberInfinityIf range is true, sets the maximum allowed distance between handles
floatBooleanfalseSet true to add a floating label above focussed handles
rangeFloatBooleanfalseIf range is true, shows the range values between handles
verticalBooleanfalseMake the slider render vertically (lower value on bottom)
pipsBooleanfalseWhether to show pips/notches on the slider
pipstepNumber1/10/20Every nth step to show a pip for. This has multiple defaults depending on values property
firstBoolean/StringfalseWhether to show a pip or label for the first value on slider. Use first='label' to show a label value
lastBoolean/StringfalseWhether to show a pip or label for the last value on slider. Use last='label' to show a label value
restBoolean/StringfalseWhether to show a pip or label for all other values. Use rest='label' to show a label value
allBoolean/StringfalseWhether to show a pip or label for all values. Same as combining first, last and rest. Use all='label' to show a label value
prefixString""A string to prefix to all displayed values
suffixString""A string to suffix to all displayed values
limitsArray[0, 100]An array of two numbers to set a limit on the handles. This overrides min and max if set, while still using them for the range display.
reversedBooleanfalseReverse the orientation of min/max
hoverableBooleantrueWhether hover styles are enabled for both handles and pips/values
disabledBooleanfalseDetermine if the slider is disabled, or enabled (only disables interactions, and events)
idString""Give the slider a unique ID for use in styling
classString""Add custom CSS classes to the slider
styleStringundefinedPass CSS variables or style declarations directly to the slider
darkmodeFalse/"auto"/"force"falseSet to "auto" to automatically detect the system's dark mode, or "light" or "dark" to force a specific mode
ariaLabelsArray[]Array of strings to use for the aria-label attribute on the handles.
formatterFunction(v,i,p) => vA function to re-format values before they are displayed (v = value, i = pip index, p = percent)
handleFormatterFunctionformatterA function to re-format values on the handle/float before they are displayed. Defaults to the same function given to the formatter property (v = value, i = handle index, p = percent)
rangeFormatterFunctionnullA function to re-format range float values (v1 = first value, v2 = second value, p1 = first percent, p2 = second percent)
springBooleantrueWhether to enable spring animations on handles
springValuesObject{ stiffness: 0.15, damping: 0.4 }Svelte spring physics object to change the behaviour of the handle when moving
precisionNumber2Precision of the values for fixing floating errors
sliderElementundefinedDOM reference for binding to the main <div /> of the component (bind:slider='ref')

๐Ÿ“”๐Ÿ” | Documentation for Options

Slider events (dispatched)

eventexampleevent.detaildescription
starton:start={(e) => { ... }}{ activeHandle: Integer, value: Float, values: Float[] }Event fired when the user begins interaction with the slider
changeon:change={(e) => { ... }}{ activeHandle: Integer, startValue: Float / Float[], previousValue: Float / Float[], value: Float, values: Float[] }Event fired when the user changes the value; returns the previous value, also
stopon:stop={(e) => { ... }}{ activeHandle: Integer, startValue: Float / Float[], value: Float, values: Float[] }Event fired when the user stops interacting with slider; returns the beginning value, also

๐Ÿ“”๐Ÿ” | Documentation for Events



Styling

Styling should mostly be done with CSS.
There's a bunch of css variables for controlling the colors of the elements. And the slider is fluid horizontally, with the size of things controlled by font-size. So you may change the font-size on the .rangeSlider base element to change the scale of everything.

If you require more fine control of the widths, heights, etc, then you may override the default css. This can be easier by using the id prop to give your slider a unique id.

Values of labels can be styled with CSS, and the format can be modified with the formatter() function prop. And animation of the handles is controlled by the springValues object prop.

๐Ÿ“”๐Ÿ” | Documentation for Styling

Note: In v4, most CSS class names have been prefixed with rs to prevent conflicts with generic CSS frameworks like DaisyUI or UnoCSS. See the upgrade guide for details.



Contribute

I am very happy to accept;

  • ๐ŸŒŸ suggestions/requests for new features or changes
  • ๐Ÿ›  pull-requests for bug fixes, or issue resolution
  • ๐Ÿ“ new recipes/examples for the docs site
  • ๐Ÿงช help with adding more tests

But please read the CONTRIBUTING.md first.



Notes

Svelte 3

โš  Because of new code added in Range Slider v3, it is incompatible with Svelte version 3.

If you are unable to upgrade your project to Svelte4/Svelte5, then I suggest looking for Svelte-Range-Slider-Pips version 2.3.1 which will not be upgraded, but it's still pretty robust. You can install it like so;

yarn add svelte-range-slider-pips@2.3.1 --dev          # or
npm install svelte-range-slider-pips@2.3.1 --save-dev  # if you prefer npm



Support / Tip

I'd be super excited if you find this project useful and wish to donate a small amount for my efforts!

ยฃ1 One Pound Tipยฃ1 GBP Tip
ยฃ5 Five Pound Tipยฃ5 GBP Tip
ยฃ10 Ten Pound Tipยฃ10 GBP Tip

Keywords

svelte

FAQs

Package last updated on 30 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts