Framer Animations & Hover Effects: A Practical Guide (With Code)

How to build Framer animations and hover effects, from native canvas interactions to code overrides, with real code snippets for buttons, cards, and scroll-based motion.

ShahulShahulUpdated Nov 30, 2026 9 min read
Framer Animations & Hover Effects: A Practical Guide (With Code)

Good Framer animations make an interface feel responsive without the visitor stopping to think about them. Bad ones do the opposite: a hover effect that fights the cursor, a scroll animation that jitters, a button that feels sluggish. The difference comes down to a handful of practical choices rather than complex math.

This guide covers Framer's native animation tools, when to reach for code overrides instead, and working TypeScript snippets you can drop into a project for button hover effects, image cards, and scroll-based motion.

Native Framer animation: what you get without code

Every layer in Framer has an Effects and Interactions panel covering three animation types.

Appear animations

Trigger when an element enters the viewport on scroll: fade in, slide up, or scale in. Delay and stagger controls let you sequence a row of cards without touching code.

Hover and tap states

Set a visual state for hover and tap/click directly on a layer or component variant, with a duration and easing curve. This covers most button and card hover effects without code.

Scroll-linked animations

Bind opacity, scale, rotation, or offset to scroll progress so an element transforms as the visitor scrolls through a section. Framer's Scroll Transform panel handles parallax and scroll-triggered reveals cleanly.

For straightforward interactions (a button that scales slightly on hover, a card that lifts on hover, a section that fades in on scroll), native tools are faster to build and easier for clients to maintain than code.

When to reach for a code override instead

Move to a code override when you hit something the visual panel doesn't expose:

  • Custom spring physics: tuning exact stiffness, damping, and mass values across hover and tap states.
  • Pointer-tracked motion: cursor-follow magnetic buttons or tilt cards that read live mouse coordinates.
  • Custom scroll value mapping: mapping scrollYProgress onto multi-stop opacity, scale, or offset curves.
  • Shared animation rules across many layers: writing one override file and attaching it to any button or card in the project.

Full reference docs for Framer's override API are in the Framer developer documentation.

Button hover effects with code: working examples

Framer's code overrides are TypeScript functions that wrap a layer and modify its props using the Motion animation library (imported in Framer from framer-motion).

To add one: open Assets → Code → New File → New Override, paste the snippet, then select your target layer on the canvas and pick the override function in the right sidebar under Code Overrides.

Scale-and-lift hover effect

import type { ComponentType } from "react"

export function withHoverLift(Component): ComponentType {
    return (props) => {
        return (
            <Component
                {...props}
                whileHover={{
                    scale: 1.04,
                    boxShadow: "0px 12px 24px rgba(0,0,0,0.15)",
                }}
                whileTap={{ scale: 0.97 }}
                transition={{ type: "spring", stiffness: 400, damping: 20 }}
            />
        )
    }
}

Apply withHoverLift to any button or card layer. The spring transition gives the lift a natural snap back instead of a rigid fixed-duration tween.

Color-shift hover effect

import type { ComponentType } from "react"
import { useState } from "react"

export function withHoverColorShift(Component): ComponentType {
    return (props) => {
        const [hovered, setHovered] = useState(false)

        return (
            <Component
                {...props}
                onHoverStart={() => setHovered(true)}
                onHoverEnd={() => setHovered(false)}
                animate={{
                    backgroundColor: hovered ? "#111111" : "#F5F5F5",
                    color: hovered ? "#FFFFFF" : "#111111",
                }}
                transition={{ duration: 0.25, ease: "easeOut" }}
            />
        )
    }
}

This works well for buttons or nav links where you want a smooth background and text inversion controlled from one place.

Magnetic hover effect (cursor-follow)

import type { ComponentType } from "react"
import { useRef } from "react"
import { useMotionValue, useSpring } from "framer-motion"

export function withMagneticHover(Component): ComponentType {
    return (props) => {
        const ref = useRef<HTMLDivElement>(null)
        const x = useMotionValue(0)
        const y = useMotionValue(0)
        const springX = useSpring(x, { stiffness: 300, damping: 20 })
        const springY = useSpring(y, { stiffness: 300, damping: 20 })

        function handleMouseMove(e: React.MouseEvent) {
            if (!ref.current) return
            const rect = ref.current.getBoundingClientRect()
            x.set((e.clientX - rect.left - rect.width / 2) * 0.3)
            y.set((e.clientY - rect.top - rect.height / 2) * 0.3)
        }

        function handleMouseLeave() {
            x.set(0)
            y.set(0)
        }

        return (
            <Component
                {...props}
                ref={ref}
                onMouseMove={handleMouseMove}
                onMouseLeave={handleMouseLeave}
                style={{ ...props.style, x: springX, y: springY }}
            />
        )
    }
}

Spreading ...props.style preserves Framer's layout positioning while useSpring smooths the pull toward the cursor. If you want magnetic buttons with configurable pull strength and mobile handling straight from the properties panel, see our Magnetic Buttons component.

Scroll-triggered animation with code

For animations tied to page scroll progress beyond what native Scroll Transforms cover:

import type { ComponentType } from "react"
import { useScroll, useTransform } from "framer-motion"

export function withScrollFade(Component): ComponentType {
    return (props) => {
        const { scrollYProgress } = useScroll()
        const opacity = useTransform(scrollYProgress, [0, 0.2, 0.8, 1], [0, 1, 1, 0])
        const y = useTransform(scrollYProgress, [0, 0.2], [40, 0])

        return <Component {...props} style={{ ...props.style, opacity, y }} />
    }
}

This maps scroll progress onto opacity and vertical offset simultaneously. Adjust the first array ([0, 0.2, 0.8, 1]) to control where along the page the fade starts and finishes.

Card and image hover effects

Contained image zoom on hover

A common portfolio and agency pattern is an image that zooms inside its card frame without pushing neighboring elements.

Set Overflow: Hidden on the parent card frame in Framer's Layout panel, then attach this override directly to the image layer inside it:

import type { ComponentType } from "react"

export function withImageZoom(Component): ComponentType {
    return (props) => {
        return (
            <Component
                {...props}
                whileHover={{ scale: 1.06 }}
                transition={{ duration: 0.35, ease: [0.22, 1, 0.36, 1] }}
            />
        )
    }
}

Because the clipping mask sits on the parent frame (Overflow: Hidden) and only scale animates on the child image, the zoom runs on the GPU without triggering layout shifts.

Staggered card reveal on scroll

Framer's Code Overrides dropdown only lists exported functions that take (Component) with no extra arguments. To stagger a three-card row cleanly, write one small helper inside the file and export one override per slot:

import type { ComponentType } from "react"

function makeStaggerReveal(delay: number) {
    return function (Component): ComponentType {
        return (props) => (
            <Component
                {...props}
                initial={{ opacity: 0, y: 20 }}
                whileInView={{ opacity: 1, y: 0 }}
                viewport={{ once: true, amount: 0.2 }}
                transition={{ duration: 0.4, delay, ease: "easeOut" }}
            />
        )
    }
}

export const withStagger1 = makeStaggerReveal(0)
export const withStagger2 = makeStaggerReveal(0.08)
export const withStagger3 = makeStaggerReveal(0.16)

Attach withStagger1, withStagger2, and withStagger3 to the three cards from Framer's Code Overrides picker. Each card enters 80ms after the previous one, and viewport={{ once: true }} prevents it from replaying every time someone scrolls back up.

Performance: which properties are safe to animate

Not all animated properties cost the same, and the gap shows up fast on mid-range phones.

Compositor-only properties stay smooth because the browser skips layout recalculation:

  • transform (scale, x, y, rotate)
  • opacity

Layout-triggering properties force the browser to recalculate geometry on every frame:

  • width and height
  • top, left, right, and bottom (when not using transform)
  • box-shadow (moderate cost; fine on one hovered button, expensive across dozens of scrolling cards)

Build hover and scroll effects around scale, x/y translation, and opacity whenever you can. For a fuller mobile speed checklist, see our Framer performance optimization guide.

Common hover and animation mistakes

Animating too many elements at once

A page where every card, badge, and headline slides in independently feels noisy. Pick two or three moments that deserve motion (a primary button, a featured image card, or a hero reveal) and leave the rest of the layout still.

Ignoring reduced-motion preferences

Visitors with motion sensitivity set prefers-reduced-motion in their OS. Check useReducedMotion() inside overrides that move or scale large elements:

import type { ComponentType } from "react"
import { useReducedMotion } from "framer-motion"

export function withRespectfulMotion(Component): ComponentType {
    return (props) => {
        const shouldReduceMotion = useReducedMotion()

        return (
            <Component
                {...props}
                whileHover={shouldReduceMotion ? {} : { scale: 1.05 }}
                transition={{ duration: shouldReduceMotion ? 0 : 0.3 }}
            />
        )
    }
}

The button still works, while skipping the motion for visitors who asked their device to cut animations.

Springs that overshoot too far

High stiffness paired with low damping creates a bouncy wobble that feels out of place on most client sites. Start conservative (stiffness: 300-400, damping: 20-30) and adjust from there.

Missing tap states and inconsistent easing

Hover does not exist on touch screens, so give buttons a visible tap/pressed state on mobile. Stick to one spring preset for interactive controls and one ease-out curve for scroll reveals across the whole site, then test the published URL on a mid-range phone rather than only on your laptop.

Using animated components without writing overrides

If you'd rather not write and maintain TypeScript overrides on every build, FramerHub Components includes 100+ pre-built code components you insert straight onto the Framer canvas and configure from the right sidebar.

FramerHub Components plugin panel inside FramerInserting pre-built animated components from the FramerHub Components plugin without writing overrides.

For cursor-driven effects, Motion Trail leaves a trail of images behind the pointer, and our free Text Pressure component shifts variable font weight and width per letter as the cursor moves across a headline.

Text Pressure cursor-reactive variable font component previewText Pressure adjusts variable font axes per character based on pointer distance.

You can preview live demos across the full FramerHub component library before deciding whether to drop in a component or write a custom override.

FAQ

Can you add animations in Framer without code?

Yes. Framer's native interactions panel supports hover, tap, appear, and scroll-triggered animations with no code, using the Effects tab on any layer. Code overrides become useful when you need custom easing curves, physics-based springs, or logic-driven animations (like a counter or a sequence) that go beyond what the visual panel exposes.

How do I add a hover effect to a button in Framer?

Select the button layer, open the Interactions panel, and add a hover state with your desired property changes (scale, color, shadow). For finer control over timing and physics, wrap the component in a code override that sets whileHover and whileTap properties with a custom transition.

What's the difference between Framer's native animations and code overrides?

Native animations are configured visually in the Effects and Interactions panels and cover most common cases: hover, tap, appear, scroll-triggered reveals. Code overrides are TypeScript functions that wrap a component and give you programmatic control: custom springs, sequenced animations, scroll-linked value mapping, and conditional logic that the visual panel doesn't support.

Do heavy animations slow down a Framer site?

They can. Animating properties like width, height, or box-shadow triggers layout recalculation and is more expensive than animating transform and opacity, which run on the compositor and stay smooth even on lower-end devices. Favor transform-based animations (scale, translate, rotate) over layout-triggering ones whenever possible.

What is a Framer code override?

A code override is a TypeScript function you write in Framer's code editor that wraps a component and modifies its props, adding animation behavior, state, or event handlers. Framer applies the override directly to a layer on the canvas without changing the component's own code, so the same base component can have different override behavior in different projects.

Skip writing animation overrides from scratch

100+ tested Framer code components with hover, scroll and cursor interactions configured in the properties panel. Includes free components.

Explore FramerHub Components
Shahul

Shahul

Founder of FramerHub

KEEP GOING

More Client handover guides

All guides