Playground

useHover

Track whether the pointer is over an element.

  • No DOM output. Hover is pointer-only: never hide essential content or actions behind it.

Import

import '@monoline/css';
import {useHover} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add use-hover

Usage

import {useHover, type Demo} from '@monoline/react';

function Demo() {
  const [ref, hovered] = useHover<HTMLDivElement>();
  return <div ref={ref} style={{padding: 'var(--s5)', border: '1px solid var(--rule)', background: hovered ? 'var(--wash-2)' : 'transparent'}}>{hovered ? 'Pointer is over this box' : 'Move the pointer here'}</div>;
}

<Demo />

Examples

Hover

Behaviour

  • No DOM output. Hover is pointer-only: never hide essential content or actions behind it.