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

react-simple-range

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-simple-range

A simple React component to input a number between a min and a max value using a slider

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-simple-range

npm version travis build

A simple React slider component for inputting a number value within a range.

Install

npm install react-simple-range --save

Usage

Import React and this component using your chosen module bundler:

import React from 'react';
import ReactDOM from 'react-dom';
import ReactSimpleRange from 'react-simple-range';
const rootElement = document.getElementById('app');

ReactDOM.render(<ReactSimpleRange />, rootElement);

Props

NameTypeDefaultDescription
minnumber0Minimum slider value
maxnumber100Maximum slider value
stepnumber1Number inc/decremented when slider value is changed. The range of the slider (max - min) should be evenly divisible by this
idstringnullIdentifier that is passed to the onChange handler (see below)
onChangefunctionNOOPFunction to be called when the slider value changes - your slider will have no effect without this! See below for more information
onChangeCompletefunctionNOOPFunction to be called when user interaction finishes, sends the same values as the onChange handler, the only difference is they get sent when the interaction has ended
defaultValuenumber0Set initial value of slider
verticalbooleanfalseSet slider to vertical when true
verticalSliderHeightstring100pxDefault slider height if vertical. If your slider already has a fixed height wrapper, just set this to 100% and the slider will fill the space
eventWrapperPaddingnumber8Px value to add padding to the wrapper to make small sliders easier to interact with
labelbooleanfalseIf true, adds a label displaying the slider's value when interacted with
disableThumbbooleanfalseDisables the thumb when true
disableTrackbooleanfalseDisables the track when true
sliderSizenumber4Px height of slider if horizontal, width if vertical
thumbSizenumbersliderSize * 2Height and width of thumb in px
sliderColorstring#9E9E9EColor of slider
trackColorstring#03A9F4Color of track and label
thumbColorstring#fffColor of thumb
customThumbelementundefinedPass in a single React element to use as your thumb, replacing the default

Change handlers

onChange

The onChange handler receives the following arguments:

  • an object containing the current slider value and ratio (percentage of bar filled)
  • the id prop of the slider

onChangeComplete

An alternative change handler which only sends the argument at the end of the mouse drag

Contributing

PRs are welcome. Submit issues for any bugs or feature requests.

Commands for local dev

NameEffect
npm startRuns react-styleguidist, serving examples at http://localhost:6060/
npm run testRuns tests with jest
npm run test:watchRuns tests in watch mode

Keywords

FAQs

Package last updated on 28 Dec 2020

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