# react-scrubber

> React scrubber component with touch controls, styling, and lots event handlers

Latest version **2.1.0** (published 2024-12-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-scrubber
pnpm add react-scrubber
yarn add react-scrubber
bun add react-scrubber
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2024-12-09 |
| First published | 2019-06-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 35.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | nick-michael |
| Maintainers | nick-michael |
| Keywords | react, react-component, slider, scrubber, input, range |

## Links

- npm: https://www.npmjs.com/package/react-scrubber
- Repository: https://github.com/nick-michael/react-scrubber
- Homepage: https://github.com/nick-michael/react-scrubber#readme
- Issues: https://github.com/nick-michael/react-scrubber/issues
- npm.io page: https://npm.io/package/react-scrubber

## Dependencies (1)

- [object.fromentries](https://npm.io/package/object.fromentries.md) ^2.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.1.0 (latest) — 2024-12-09
- 2.0.0 — 2023-07-13
- 1.2.0 — 2023-07-11
- 1.1.1 — 2022-08-15
- 1.1.0 — 2022-08-15
- 1.0.3 — 2022-08-15
- 1.0.2 — 2020-12-17
- 1.0.1 — 2020-12-17
- 1.0.0 — 2020-04-02
- 0.4.0 — 2019-09-12
- 0.3.1 — 2019-08-28
- 0.3.0 — 2019-08-28
- 0.2.8 — 2019-06-13
- 0.2.7 — 2019-06-12
- 0.2.6 — 2019-06-12
- … 9 more at https://npm.io/package/react-scrubber/versions

## README

# [react-scrubber](https://nick-michael.github.io/react-scrubber/)
A simple React scrubber component with touch controls, styling, and event handlers. Integrated TypeScript support. See more information and a live demo at [https://nick-michael.github.io/react-scrubber/](https://nick-michael.github.io/react-scrubber/)

The code for the above demo can be found inside the repository in the '/demo' folder.

## Dependencies
React is listed as a peer dependency. React should be added as a dependency to your project. The component provides its styling with a CSS stylesheet (`scrubber.css`) file, so you'll need to import it and have webpack set up to handle css imports. The typical combination of `style-loader` and `css-loader` works great!

## Usage
```js
import  React, { Component } from  'react';
import { Scrubber, ScrubberProps } from 'react-scrubber';
// Note: ScrubberProps is a TypeScript interface and is not used for JS projects

import 'react-scrubber/lib/scrubber.css'

class App extends Component {
  state = {
    value: 50,
    state: 'None',
  }

  handleScrubStart  = (value:  number) => {
    this.setState({ value, state:  'Scrub Start' });
  }

  handleScrubEnd  = (value:  number) => {
    this.setState({ value, state:  'Scrub End' });
  }

  handleScrubChange  = (value:  number) => {
    this.setState({ value, state:  'Scrub Change' });
  }

  render() {
    return (
      <div  className="scrubber-container"  style={{ height:  '20px' }}>
        <Scrubber
          min={0}
          max={100}
          value={this.state.value}
          onScrubStart={this.handleScrubStart}
          onScrubEnd={this.handleScrubEnd}
          onScrubChange={this.handleScrubChange}
        />
      </div>
    );
  }
}
```

## Props
| Name | Type | Required | Description |
|--|--|--|--|
| className | string | No | Sets the class name for the scrubber div
| value | number | Yes | Set current value of slider
| min | number | Yes | The minimum value of the slider
| max | number | Yes | The maximum value of the slider
| bufferPosition | number | No | Some number higher than the value, used to render a 'buffer' indicator
| vertical | boolean | No | The scrubber will render vertically
| onScrubStart | function | No | Called on mouse down or touch down
| onScrubEnd | function | No | Called on mouse up or touch up while scrubbing
| onScrubChange | function | No | Called on mouse move while scrubbing
| onMouseMove | function | No | Called with the scrub value of the cursor position when the mouse moves inside the scrubber element
| onMouseOver | function | No | Called with the scrub value of the cursor position when the mouse enters scrubber element
| onMouseLeave | function | No | Called with the scrub value of the cursor position when the mouse leaves scrubber element
| markers | Array<number \| { start: number, end?: number, className?: string }> | No | Adds yellow indicators to the scrubber bar
| tooltip | {<br /> &emsp;enabledOnHover?: boolean;<br /> &emsp;enabledOnScrub?: boolean;<br /> &emsp;className?: string;<br /> &emsp;formatString?: (value: number) => string;<br/>} | No | Renders a tooltip while hovering/scrubbing
| custom props | any | No | Any other props will be applied to the outermost 'scrubber' div

---
_Source: https://npm.io/package/react-scrubber · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
