Coder Social home page Coder Social logo

tanyaignatenko / react-range-slider Goto Github PK

View Code? Open in Web Editor NEW
3.0 0.0 1.0 4.47 MB

Common UI component Range-Slider (React, JavaScript)

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

License: MIT License

HTML 1.70% JavaScript 83.58% SCSS 14.72%

react-range-slider's Introduction

Range Slider for your react app

A common component to select numeric ranges.

Features

  • Draggable handles
  • Draggable selectedRange
  • Handles can be crossed

DEMO

Screenshots

Component screenshots

Usage

import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import RangeSlider from 'react-range-slider';

const toPriceLabel = price => `$${price}`;

function App() {
  const [selectedPriceRange, setSelectedPriceRange] = useState({
    start: 600,
    end: 3000,
  });

  return (
    <RangeSlider
      min={100}
      max={3000}
      valuePerStep={100}
      labelMarkStep={5}
      selectedRange={selectedPriceRange}
      onChange={setSelectedPriceRange}
      formatLabel={toPriceLabel}
    />
  );
}

ReactDOM.render(<App />, document.getElementById('app'));

API

min: number

Set a minimum value that can be selected

max: number

Set a maximum value that can be selected

selectedRange: { start: number, end: number }

Set current selected range. Have no effect while drag happening.

onChange: (range: { start: number, end: number }): void

Whenever user drags slider handles/range, this function gets called. Inside the function, you should assign a new selected range to your component.

formatLabel: (value: number): string

Format label of given value.

valuePerStep?: number

Set step to get next value from current. Default: 1.

labelMarkStep?: number

Set step per which label mark would be printed. Default: 4.

className?: string

Add className to component outermost container. Default: ''.

License

MIT

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.