npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-multi-bar-slider

v1.4.0

Published

Slider component with multiple bars for React

Downloads

414

Readme

react-multi-bar-slider

Slider component with multiple bars for React.

Demo repo

Multi slider screenshot

Install

yarn add react-multi-bar-slider or npm install --save react-multi-bar-slider

Usage

See the demo repo.

Basic example

import MultiSlider, { Progress } from 'react-multi-bar-slider';

export default class App extends Component {
  state = {
    progress: 10
  };

  handleSlide = newProgress => this.setState({ progress: newProgress });

  render() {
    return (
      <MultiSlider onSlide={this.handleSlide}>
        <Progress color="green" progress={this.state.progress} />
        <Progress color="purple" progress={45} />
      </MultiSlider>
    );
  }
}

Advanced example

import MultiSlider, { Progress, Dot } from 'react-multi-bar-slider';

export default class App extends Component {
  state = {
    progress: 10
  };

  handleSlide = newProgress => this.setState({ progress: newProgress });

  render() {
    return (
      <MultiSlider
        width={600}
        height={20}
        slidableZoneSize={40}
        backgroundColor="bisque"
        equalColor="blue"
        style={{ marginBottom: 40 }}
        onSlide={this.handleSlide}
        onDragStart={progress => console.log(`Started dragging: ${progress}%`)}
        onDragStop={progress => console.log(`Stopped dragging: ${progress}%`)}
        roundedCorners
        reversed
      />
        <Progress color="green" progress={this.state.progress}>
          <Dot color="grey" />
        </Progress>
        <Progress color="purple" progress={45}>
          <Dot color="grey" />
        </Progress>
      </MultiSlider>
    );
  }
}

Props

* = Required

MultiSlider

Prop | Description | Type | Default ---- | ----------- | ---- | ------- width | Width of the slider | number or string | 100% height | Height of the slider | number or string | 14px slidableZoneSize | Size of the zone in which sliders can be dragged | number or string | 7px, backgroundColor | Background color of the slider | string | #EEEEEE equalColor | Color of all bars when their values are equal | string | style | Custom style for the slider Signature: function(props: object) => object | object or function | {} onSlide | Callback that is fired when the progress was set Signature: function(progress: number) => void | function | onDragStart | Callback function that is fired when the slider has begun to move Signature: function(progress: number) => void | function | onDragStop| Callback function that is fired when the slide has stopped moving Signature: function(progress: number) => void | function | roundedCorners | When set to true, the slider has rounded corners | bool | false reversed | When set to true, the slider is reversed | bool | false readOnly | When set to true, the slider can't be updated | bool | false children* | The progress bars that are shown in the slider (or any other children) | node |

All other props (not documented here) will be passed on to the root element.

Progress

Prop | Description | Type | Default ----- | ----------- | ---- | ------- color* | Color of the progress bar | string | progress* | Progress of the progress bar | number | style | Custom style for the progress bar Signature: function(props: object) => object | object or function | children | The slider dot (or any other children) | node |

All other props (not documented here) will be passed on to the root element.

Dot

Prop | Description | Type | Default ----- | ----------- | ---- | ------- width | Width of the dot | number or string | 50 when the dot has an icon, 28 if not height | Height of the dot | number or string | 50 when the dot has an icon, 28 if not color | Color of the dot | string | icon | URL of the image to use as dot icon | string | style | Custom style for the dot Signature: function(props: object) => object | object or function | iconStyle | Custom style for the dot icon Signature: function(props: object) => object | object or function | children | Children of the dot | node |

All other props (not documented here) will be passed on to the root element.

How custom styles work

When a function is passed to a style prop rather than an object, it is expected to return an object. The style function will be called with all props that that component has (except for the style and children props and any internal callbacks). The return value of the function will be used as style (see the demo repo for an example).