react-range icon indicating copy to clipboard operation
react-range copied to clipboard

How to disable specific thumb in multi-range slider?

Open MrPhyaeSoneThwim opened this issue 4 years ago • 1 comments

I am now using react-range lib to add multi-range slider in my project. And I want to disable the specific thumb instead of the whole layout of range slider. Is it possible to do that?

MrPhyaeSoneThwim avatar Mar 13 '22 09:03 MrPhyaeSoneThwim

Found a workaround. I created a function for the Range onChange so that it only updates the values i want.

const [thumb1, setThumb1] = useState(0)
const [thumb2, setThumb2] = useState(10)

function updateValues(values){
   setThumb2(values[1])
}

<Range
values={[thumb1, thumb2]}
onChange={(values) => updateValues(values)}
...
/>

This will make it so when you click on the first thumb nothing will happen. Just have to set css on the thumb so that if index == 0 cursor is normal

Egr711 avatar Jun 02 '22 16:06 Egr711