Skip to main content

Documentation

Let's discover React Range Slider in less than 2 minutes.

Getting Started

Get started by installing the package.

npm install @inkdev/react-range-slider

Props

PropTypeRequiredDefault ValueDescription
valuenumberYesN/ACurrent value of the slider
onChangeChangeEventHandler<HTMLInputElement>YesN/AEvent handler for value change
componentWidthstringNo'100%'Width of the component
disabledbooleanNofalseWhether the component is disabled
sliderColorstringNo'#77bb41'Color of the slider
trackBgColorstringNo'#F2F1F1'Background color of the track
trackBorderColorstringNo'#E7E6E4'Border color of the track
categoryNamestringNoN/ACategory name
maxnumberNo10Maximum value of the slider
minnumberNo0Minimum value of the slider
tooltipPosition'above' | 'under'No'under'Position of the tooltip relative to the slider
labelsbooleanNotrueWhether to display labels

Usage

import React from 'react';
import { RangeSlider, RangeSliderProps } from '@inkdev/react-range-slider';
import { useState } from 'react';

const MyComponent = () => {
const [value, setValue] = useState(0);

const handleOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const newValue = parseInt(e.target.value, 10);
setValue(newValue);
};

const sliderProps: RangeSliderProps = {
componentWidth: '100%',
disabled: false,
sliderColor: '#77bb41',
trackBgColor: '#F2F1F1',
trackBorderColor: '#E7E6E4',
value: value,
onChange: handleOnChange,
categoryName: '',
max: 10,
min: 0,
tooltipPosition: 'under',
labels: true,
};

return <RangeSlider {...sliderProps} />;
};

export default MyComponent;