Search

Back

Copy Link

Library

/

Free

/

4

Material Ripples

4

Material Ripples

Not loading? Preview

Made by

@frameroverrides

override

click

Override

Material Ripples

Copy

Override

Copied to Clipboard!

Instructions

  1. Apply to a frame separate from your button frame

  2. Place that frame inside your button stack or frame

  3. Set the frame holding the effect to absolute position

  4. Set 0 pixels on all sides to ensure scaling

  5. You may need to change the Z-index of text to ensure it appears behind the effect

Code Preview

import { Override, motion } from "framer-motion"
import * as React from "react"

export function MaterialClickEffect(): Override {
    const [ripples, setRipples] = React.useState([])

    const handleClick = (event) => {
        // Get the container dimensions
        const rect = event.currentTarget.getBoundingClientRect()

        const x = event.clientX - rect.left
        const y = event.clientY - rect.top

        setRipples([...ripples, { x, y, id: Date.now() }])

        // Remove the ripple after 600ms
        setTimeout(() => {
            setRipples((prevRipples) => prevRipples.slice(1))
        }, 600)
    }

    return {
        onClick: handleClick,
        children: ripples.map((ripple) => (
            <motion.div
                key={ripple.id}
                initial={{ opacity: 1, scale: 0 }}
                animate={{ opacity: 0, scale: 2 }}
                transition={{ duration: 0.6, ease: "linear" }}
                style={{
                    position: "absolute",
                    width: "100px",
                    height: "100px",
                    top: ripple.y - 50, // Adjust the ripple position
                    left: ripple.x - 50, // Adjust the ripple position
                    background: "rgba(255, 255, 255, 0.3)",
                    borderRadius: "50%",
                }}
            />
        )),
    }
}

Terms of Use for Free Assets

By accessing and using this Framer Override Library, you agree to the following terms:

All code snippets provided are available for your personal and professional use. This includes personal websites, client projects, and other website projects in Framer. You are strictly prohibited from sharing, redistributing, selling these code snippets, or creating derivative works for resale or distribution. Unauthorized sharing, distribution, or selling of these code snippets is a breach of these terms and may result in termination of your access to this library, along with potential legal action.