Sign up and get 15% off every plan.

Sign up
Menu
SlidersMantine UIMIT licenceFree

Slider with a hover handle

A slider whose handle shows only when you point at it.

Add it to your project

Or install the packages yourselfTerminal
npm install @mantine/core @mantine/hooks

The code

components/SliderHover/SliderHover.tsxReact
/**
 * 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,
        },
      }}
    />
  );
}