Make your AI a shadcn expert

React useHover Hook

React useHover hook to track mouse hover state on any element. Returns boolean, uses ref, auto-cleanup. TypeScript ready.

React useHover Hook preview

Scroll to load preview

Detect hover state on any React element with a single hook. useHover takes a ref and returns true when the mouse is over the element. Uses mouseenter/mouseleave events internally—no CSS required, works with any element type. Auto-cleans up listeners on unmount. Perfect for hover cards, tooltips, interactive buttons, image galleries, or any UI that responds to mouse position. TypeScript generic for element types. SSR safe—only attaches listeners client-side. Works with Next.js App Router and any React framework.

Install with AI

If you've connected the shadcn.io MCP server to Claude Code, Cursor, Windsurf, or any MCP-ready AI editor, prompt your agent to install this hook for you — no copy-paste, no CLI:

use shadcnio to install the use-hover hook into my project

FAQ

Was this page helpful?

Sign in to leave feedback.