Slider with a hover handle
A slider whose handle shows only when you point at it.
A slider whose handle shows only when you point at it.
npm install @mantine/core @mantine/hooks
First time with Mantine UI? Set it up once.
/**
* Component from Mantine UI, https://ui.mantine.dev
* MIT License, Copyright (c) 2022 Vitaly Rtischev. Full text: https://github.com/mantinedev/ui.mantine.dev/blob/master/LICENCE
*/
import { Slider } from '@mantine/core';
import { useHover } from '@mantine/hooks';
export function SliderHover() {
const { hovered, ref } = useHover();
return (
<Slider
defaultValue={40}
min={10}
max={90}
ref={ref}
label={null}
thumbLabel="Hover slider"
styles={{
thumb: {
transition: 'opacity 150ms ease',
opacity: hovered ? 1 : 0,
},
}}
/>
);
}