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

@figlinq/react-rangeslider

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@figlinq/react-rangeslider

A lightweight react component that acts as a HTML5 input range slider polyfill

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19
decreased by-52.5%
Maintainers
2
Weekly downloads
 
Created
Source

react-rangeslider

A fast & lightweight react component as a drop in replacement for HTML5 input range slider element.

This is a fork of appigram/react-rangeslider which in turn is a fork of whoisandy/react-rangeslider. The intention is to fix some bugs and otherwise keep it in sync with appigram/react-rangeslider.

Installation

Using npm (use --save to include it in your package.json)

$ npm install react-rangeslider --save

Using yarn (this command also adds react-rangeslider to your package.json dependencies)

$ yarn add react-rangeslider

Getting Started

React-Rangeslider is bundled with a slider component & default styles which can be overridden depending on your design requirements.

With a module bundler like webpack that supports either CommonJS or ES2015 modules, use as you would anything else:

// Using an ES6 transpiler like Babel
import Slider from 'react-rangeslider'

// To include the default styles
import 'react-rangeslider/lib/index.css'

// Not using an ES6 transpiler
var Slider = require('react-rangeslider')

The UMD build is also available on unpkg:

<script src="https://unpkg.com/react-rangeslider/umd/rangeslider.min.js"></script>

You can find the library on window.ReactRangeslider. Optionally you can drop in the default styles by adding the stylesheet.

<link rel="stylesheet" href="https://unpkg.com/react-rangeslider/umd/rangeslider.min.css" />

Check out docs & examples.

Basic Example

import React, { Component } from 'react'
import Slider from 'react-rangeslider'

class VolumeSlider extends Component {
  constructor(props, context) {
    super(props, context)
    this.state = {
      volume: 0
    }
  }

  handleOnChange = (value) => {
    this.setState({
      volume: value
    })
  }

  render() {
    let { volume } = this.state
    return (
      <Slider
        value={volume}
        orientation="vertical"
        onChange={this.handleOnChange}
      />
    )
  }
}

API

Rangeslider is bundled as a single component, that accepts data and callbacks only as props.

Component

import Slider from 'react-rangeslider'

// inside render
<Slider
  min={Number}
  max={Number}
  step={Number}
  value={Number}
  orientation={String}
  reverse={Boolean}
  tooltip={Boolean}
  labels={Object}
  handleLabel={String}
  format={Function}
  onChangeStart={Function}
  onChange={Function}
  onChangeComplete={Function}
/>

Props

PropTypeDefaultDescription
minnumber0minimum value the slider can hold
maxnumber100maximum value the slider can hold
stepnumber1step in which increments/decrements have to be made
valuenumbercurrent value of the slider
orientationstringhorizontalorientation of the slider
tooltipbooleantrueshow or hide tooltip
reversebooleanfalsereverse direction of vertical slider (top-bottom)
labelsobject{}object containing key-value pairs. { 0: 'Low', 50: 'Medium', 100: 'High'}
handleLabelstring''string label to appear inside slider handles
formatfunctionfunction to format and display the value in label or tooltip
onChangeStartfunctionfunction gets called whenever the user starts dragging the slider handle
onChangefunctionfunction gets called whenever the slider handle is being dragged or clicked
onChangeCompletefunctionfunction gets called whenever the user stops dragging the slider handle.

Development

To work on the project locally, you need to pull its dependencies and run npm start.

$ npm install
$ npm start

Issues

Feel free to contribute. Submit a Pull Request or open an issue for further discussion.

License

MIT

Keywords

FAQs

Package last updated on 03 Nov 2023

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