Skip to content

Framer Motion Gesture Not Working — Fix whileHover/whileTap

DodaTech Updated 2026-06-24 1 min read

In this fix, you'll learn how to use Framer Motion gestures for interactions. This matters for interactive UI elements, and appears in buttons, cards, and draggable items.

The Problem

The following code demonstrates the typical mistake:

<div whileHover={{ scale: 1.1 }}>Hover me</div>
// No effect — regular div doesn't support gesture props

The Fix

Here is the corrected version:

<motion.div whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.95 }}>
  Hover me
</motion.div>
// Scales on hover and tap

Prevention

  • Always use motion elements (motion.div, motion.button) for gesture animations.
  • Gesture props include: whileHover, whileTap, whileDrag, whileFocus, whileInView.
  • Multiple gesture props can be combined on the same element.
  • Use transition to customize gesture animation physics.
  • For complex gestures, define variants and reference them in gesture props.

Common Mistakes with framer motion gesture

  1. Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
  2. Using head and tail instead of pattern matching, causing runtime errors on empty lists
  3. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks

These mistakes appear frequently in real-world REACT code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What gesture props does Framer Motion support?

whileHover (mouse hover), whileTap (press/click), whileDrag (during drag), whileFocus (keyboard focus), whileInView (when scrolled into viewport).

How do I disable text selection during drag?

Set drag='x' and style with userSelect: 'none'. Framer Motion applies this automatically during drag.

Can gestures work with Variants?

Yes — define variants and use whileHover='hover' whileTap='tap' variants={variants}.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro