An open API service indexing awesome lists of open source software.

https://github.com/gilbarbara/react-range-slider

A range slider component for React
https://github.com/gilbarbara/react-range-slider

Last synced: 9 months ago
JSON representation

A range slider component for React

Awesome Lists containing this project

README

          

# react-range-slider

[![npm version](https://badge.fury.io/js/%40gilbarbara%2Freact-range-slider.svg)](https://badge.fury.io/js/%40gilbarbara%2Freact-range-slider) [![CI](https://github.com/gilbarbara/react-range-slider/actions/workflows/main.yml/badge.svg)](https://github.com/gilbarbara/react-range-slider/actions/workflows/main.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/cc1a3d9dd8e9731beeaf/maintainability)](https://codeclimate.com/github/gilbarbara/react-range-slider/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/cc1a3d9dd8e9731beeaf/test_coverage)](https://codeclimate.com/github/gilbarbara/react-range-slider/test_coverage)

A range slider component for React

View the [demo](https://codesandbox.io/s/github/gilbarbara/react-range-slider/tree/main/demo)

## Installation

```sh
npm i @gilbarbara/react-range-slider
```

## Usage

```typescript
import React, { useState } from 'react';
import RangeSlider, { RangeSliderPosition, RangeSliderProps } from '@gilbarbara/react-range-slider';

export default function App() {
const [x, setX] = useState(10);

const handleChange = (position: RangeSliderPosition, props: RangeSliderProps) => {
setX(position.x);
};

return ;
}
```

## Props

**axis** {'x' | 'y' | 'xy'} ▶︎`x`
Type of slider

**x** {number}
Use with axis `x` or `xy`

**xMin** {number} ▶︎`0`
Min value of X

**xMax** {number} ▶︎`100`
Max value of X

**xStep** {number} ▶︎`1`
Step of X

**y** {number}
Use with axis `y` or `xy`

**yMin** {number} ▶︎`0`
Min value of Y

**yMax** {number} ▶︎`100`
Max value of Y

**yStep** {number} ▶︎`1`
Step of Y

**onAfterEnd** {function}
It is called after the slider changed (click or drag)

**onChange** {function}
It is called for each step

**onDragEnd** {function}
It is called after dragging the thumb

## Customization

You can customize the UI with a `styles` prop.
Check out [styles.ts](src/styles.ts) for more information.

```jsx

```

## License

MIT