Coder Social home page Coder Social logo

imshaikot / react-metro-range-slider Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 755 KB

HTML5 range slider standalone UI component for react

Home Page: https://imshaikot.github.io/react-metro-range-slider

License: MIT License

JavaScript 83.11% CSS 16.89%
react range-slider html5 metro-layout range-slider-prototype javascript input-slider

react-metro-range-slider's Introduction

Metro layout range slider for React

Tiny react UI component for modern metro layout based range slider prototype.

Demo

https://imshaikot.github.io/react-metro-range-slider/

Installation

$ npm install react-metro-range-slider --save

Getting Started

There's a lot of other range-slider available for different design purposes - this one will lets you bring the metro layout and the slider by itself very thin :) It's very easy to start with this range slider if you're using any bundler (whether CommonJS or ES6 import).

// Using ES6
import RangeSlider from 'react-metro-range-slider';
import 'react-metro-range-slider/lib/index.css';

// Not using ES6
var RangeSlider = require('react-rangeslider');

Example and API

import React from 'react';

import RangeSlider from 'react-metro-range-slider';
import 'react-metro-range-slider/lib/index.css';

class MyComponent extends React.Component {
  constructor(props, context) {
    super(props, context)
    this.state = {
      my_value: 0
    }
  }

  onChange(event, value) {
    this.setState({
      my_value: value
    })
  }

  render() {
    return (
      <RangeSlider
        onChange={(e, v) => this.onChange(e, v)} // [Optional] in order to track the chages
        onChangeStart={(e, v) => console.log(e, v)} // [Optional] fires when change/drag starts
        onChangeEnd={(e, v) => console.log(e, v)} // [Optional] fires when change/drag ends

        colorPalette={{fill: '#F97D4E', toFill: '#939292', thumb: '#FD5412'}} // [Optional] to set color palette to the slider

        max={50} // [Optional] [Default: 100]
        min={-20} // [Optional] [Default: 0]
        preValue={10} // [Optional] [Default: 0] to set prefilled value

        disabled={true} // [Optional] [Default: false] to set the slider in dsiabled state

        value={0} // [Optional] this one is very important - it won't update on change and you shouldn't assign the updated value on it. The purpose of using this prop is to set any data to set during the runtime (ex. any async value)

        onPreModal={(value) => Math.round(value) } // [Optional] to show a predictional tooltip, you should pass a function and return the filtered value to it. If the function returns undefined, it'll show the current value on the tooltip
      />
    )
  }
}

react-metro-range-slider's People

Contributors

imshaikot avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.