Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/therealparmesh/use-hovering

Simple, accessible React hook for tracking hover state.
https://github.com/therealparmesh/use-hovering

Last synced: 11 days ago
JSON representation

Simple, accessible React hook for tracking hover state.

Awesome Lists containing this project

README

        

# use-hovering 🧞

> Simple, accessible React hook for tracking hover state.

[![npm](https://img.shields.io/npm/v/use-hovering.svg)](https://www.npmjs.com/package/use-hovering)
[![npm](https://img.shields.io/npm/dt/use-hovering.svg)](https://www.npmjs.com/package/use-hovering)

## Install

```sh
npm install use-hovering
```

## Usage

### Plain

```jsx
import { useHovering } from 'use-hovering';

export const Example = () => {
const ref = React.useRef();
const hovering = useHovering(ref);

return (


Hover over me!{hovering && ' Hovering!'}

);
};
```

### With delay

```jsx
import { useHovering } from 'use-hovering';

export const Example = () => {
const ref = React.useRef();
const hovering = useHovering(ref, {
enterDelay: 250,
exitDelay: 250,
});

return (


Hover over me!{hovering && ' Hovering!'}

);
};
```