Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-range-slider-pips

Package Overview
Dependencies
Maintainers
1
Versions
37
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

  • 1.7.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.7K
increased by7.61%
Maintainers
1
Weekly downloads
 
Created
Source

Range Slider (with pips)

svelte-range-slider-pips @ npm

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

Svelte Range Slider -- focussed, including some pips


📔ExternalFull Documentation & Examples
💲REPLSvelte component demo
CodepenPlain JS component demo

features

Features of the range slider plugin (written below)

  • ✨ fully customisable, stylable & accessible
  • 👍🏽 multi-thumb
  • 🎚 range (min/max)
  • 🏷 floating labels
  • 📏 ruler notches
  • 🏷 labels for notches
  • 🧮 step function
  • 🖍 formatter
  • 🎭 animated

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

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 either with a regular <script> tag. This should even work with jQuery.

<script src="./js/vendor/svelte-range-slider-pips.js" />

<div id="my-slider"></div>

<script>
  var mySlider = new RangeSliderPips({
    target: document.getElementById("my-slider"),
    props: { /* props as js object */ }
  });
</script>

in a svelte project

Assuming you have a Svelte app up and running;

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

<RangeSlider />

as a JS module

If you're building a bleeding-edge JS application (not svelte), 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: { /* props as js object */ }
});

props (options)

slider props

proptypedefaultdescription
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
maxNumber100Maximum value for the slider
stepNumber1Every nth value to allow handle to stop at
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
floatBooleanfalseSet true to add a floating label above focussed handles
verticalBooleanfalseMake the slider render vertically
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
disabledBooleanfalseDetermine if the slider is disabled, or enabled (only disables interactions, and events)
formatterFunction(v) => vA function to re-format values before they are displayed
handleFormatterFunctionformatterA function to re-format values on the handle/float before they are displayed. Defaults to the same function given to the formatter property
springValuesObject{ stiffness: 0.15, damping: 0.4 }Svelte spring physics object to change the behaviour of the handle when moving

slider events (dispatched)

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

📔📘📖 Full Documentation & Examples

contribute

I am very happy to accept;

  • 🌟 suggestions/requests for new features or changes
  • 🛠 pull-requests for bug fixes, or issue resolution
  • 🧪 help with creating a proper test-suite

Read the CONTRIBUTING.md

Keywords

FAQs

Package last updated on 30 Jun 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc