๐Ÿ–ฑor โŒจ๏ธ? ๐Ÿคทโ€โ™€๏ธ, but hopefully use-hover-state works on the "user intent" not the "device"

Related tags

React react a11y
Overview

useHoverState()

The one aware of keyboard navigation as well ๐Ÿ˜‰

Bundlephobia Types MIT License

npm i use-hover-state

A React hook for tracking user interaction with the DOM elements, combining ๐Ÿ–ฑ mouse events and โŒจ๏ธ keyboard focus

Quick Start

import * as React from 'react';
import { useHoverState } from 'use-hover-state';

const Component = (props) => {
  const [isHovering, hoverState] = useHoverState();
  return <div {...hoverState}>{isHovering ? 'Hovering' : 'Not hovering'}</div>;
};

API

useHoverState(options?)

Returns [boolean, spreadProps]

This hook returns a tuple with the:

  • boolean isHovered state, representing current active state of an element
  • object spreadProps, which one should spread on the given element
  • object realState, which one can use to distinguish mouse and keyboard activity

HoverOptions

Property Type Description
enterDelay number Delays setting isHovering to true for this amount in ms
leaveDelay number Delays setting isHovering to false for htis amount in ms

You almost certainty need to set leaveDelay to a non zero value

supportsHover

A hover feature detector

import { supportsHover } from 'react-hover-state';

switch (supportsHover()) {
  case true:
    'yes';
  case false:
    'no';
  default:
    'this is server';
}

See also

LICENSE

MIT

You might also like...

This hook allows you to isolate and manage the state within the component, reducing rendering operations and keeping the source code concise.

React Hook Component State This hook allows you to isolate and manage the state within the component, reducing rendering operations and keeping the so

May 15, 2022

Twitter-Clone-Nextjs - Twitter Clone Built With React JS, Next JS, Recoil for State Management and Firebase as Backend

Twitter Clone This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn de

Feb 7, 2022

Whoosh - minimalistic React state manager

Whoosh - minimalistic React state manager

Whoosh - minimalistic React state manager Whoosh is a React state manager which entire API consists of exactly one function - createShared(). TL;DR ve

Nov 7, 2022

๐Ÿ”ฎ tiny robust state management

๐Ÿ”ฎ snapstate tiny robust state management ๐Ÿ“ฆ npm install @chasemoskal/snapstate ๐Ÿ‘๏ธ watch for changes to properties ๐Ÿ•ต๏ธ track only the properties you

Dec 23, 2022

React Native's Global Alert Component that can be fully customized and without the need of a state.

React Native's Global Alert Component that can be fully customized and without the need of a state.

๐Ÿšฉ React Native Easy Alert React Native Easy Alert Component. Watch on youtube Easy Alert example app. React Native's Global Alert Component that can

Feb 21, 2022

Small (0.5 Kb) react hook for getting media breakpoints state info in runtime

tiny-use-media Small (0.5 Kb) react hook for getting media breakpoints state info in runtime Usage npm i tiny-use-media --save Adn in your react code

Dec 13, 2022

Edvora App is a web application based on an external API, showing data about different types of products and the user can filter these data by choosing a specific state, city or product name. Build with React.js

 Edvora App is a web application based on an external API, showing data about different types of products and the user can filter these data by choosing a specific state, city or product name. Build with React.js

Edvora App is a web application based on an external API, showing data about different types of products and the user can filter these data by choosing a specific state, city or product name. Build with React.js

Mar 11, 2022

A tiny package for JavaScript Web App's state management based on RxJS & Immer

A tiny package for JavaScript Web App's state management based on RxJS & Immer

Oct 19, 2022

Tiny and powerful state management library.

Tiny and powerful state management library.

BitAboutState Tiny and powerful React state management library. 100% Idiomatic React. Install npm install --save @bit-about/state Features 100% Idioma

Nov 5, 2022
Owner
Marina
Mother of 3 and React developer. @thekashey's wife.
Marina
Create a performant distributed context state by synergyzing atomar context pieces and composing reusable state logic.

Synergies Create a performant distributed context state by synergyzing atomar context pieces and composing reusable state logic. synergies is a tiny (

Lukas Bach 8 Nov 8, 2022
Learning how to use redux - a state management library

Redux Learning how to use redux - a state management library What is Redux? Redux is a state management library for JS apps. It centralizes applicatio

Melvin Ng 3 Jul 18, 2022
An experimental hover effect, where a content preview is shown while a mini map indicates the position of the cursor.

Hover Preview Effect with Mini Map An experimental hover effect, where a content preview is shown while a mini map indicates the position of the curso

Codrops 27 Dec 29, 2022
A Higher Order Component using react-redux to keep form state in a Redux store

redux-form You build great forms, but do you know HOW users use your forms? Find out with Form Nerd! Professional analytics from the creator of Redux

Redux Form 12.6k Jan 3, 2023
Recoil is an experimental state management library for React apps. It provides several capabilities that are difficult to achieve with React alone, while being compatible with the newest features of React.

Recoil ยท Recoil is an experimental set of utilities for state management with React. Please see the website: https://recoiljs.org Installation The Rec

Facebook Experimental 18.2k Jan 8, 2023
๐Ÿป Bear necessities for state management in React

A small, fast and scaleable bearbones state-management solution. Has a comfy api based on hooks, isn't boilerplatey or opinionated, but still just eno

Poimandres 25.5k Jan 9, 2023
๐Ÿ High performance subscription-based form state management for React

You build great forms, but do you know HOW users use your forms? Find out with Form Nerd! Professional analytics from the creator of React Final Form.

Final Form 7.2k Jan 7, 2023
A state management library for React, heavily inspired by vuex

Vuex - But for React! โš› If you know vuex, you know it's as close as we get to a perfect state management library. What if we could do this in the reac

Dana Janoskova 103 Sep 8, 2022
Real state property listing app using next.js , chakra.ui, SCSS

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

null 1 Dec 19, 2021
experimental project for babel-plugin-mutable-react-state

Goalist Mutable React Example This example is an attempt to work with babel-plugin-mutable-react-state on a simpler project to see how complicated wou

Reaper 1 Jun 7, 2022