The RangeSlider component is a highly customizable React Native range slider. It allows you to render your own thumbs, rails, labels, and notches, providing full control over the UI while managing the slider logic (min/max, steps, and range constraints) internally.
To use it, you must provide render functions for the thumbs, the rail, and the selected rail. You can also optionally provide render functions for labels and notches that follow the thumbs during interaction.
import React from 'react';
import { View, Text } from 'react-native';
import Slider from 'rn-range-slider';
const MySlider = () => {
return (
<Slider
min={0}
max={100}
step={1}
renderThumb={(name) => (
<View key={name} style={{ width: 20, height: 20, borderRadius: 10, backgroundColor: 'blue' }} />
)}
renderRail={() => (
<View style={{ height: 4, backgroundColor: 'gray', width: '100%' }} />
)}
renderRailSelected={() => (
<View style={{ height: 4, backgroundColor: 'blue', width: '100%' }} />
)}
onValueChanged={(low, high, byUser) => {
console.log('New range:', low, high, 'Changed by user:', byUser);
}}
/>
);
};