Search

Back

Copy Link

Library

/

Free

/

39

Orb

39

Orb

Not loading? Preview

Made by

@frameroverrides

override

hover

Override

Orb

Copy

Override

Copied to Clipboard!

Instructions

  1. Put the orb in it's own frame

  2. Create a stack around the orb

  3. Set the orb frame to be positioned relative and set height and width to 150%

  4. Make sure overflow is hidden on the frame around your orb

  5. Line 7 of the code allows you to adjust the colors colors = ["turquoise", "violet", "blue", "pink"]


Code Preview

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

export function withColorfulGradientHover(
    Component,
    colors = ["turquoise", "violet", "blue", "pink"]
): ComponentType {
    return (props) => {
        const gradientRef = useRef(null)
        const containerRef = useRef(null)
        const cursorPosition = useRef({
            x: window.innerWidth / 2,
            y: window.innerHeight / 2,
        })

        const handleMouseMove = (event) => {
            cursorPosition.current = { x: event.clientX, y: event.clientY }
        }

        const handleTouchMove = (event) => {
            cursorPosition.current = {
                x: event.touches[0].clientX,
                y: event.touches[0].clientY,
            }
        }

        useEffect(() => {
            window.addEventListener("mousemove", handleMouseMove)
            window.addEventListener("touchmove", handleTouchMove)
            return () => {
                window.removeEventListener("mousemove", handleMouseMove)
                window.removeEventListener("touchmove", handleTouchMove)
            }
        }, [])

        useEffect(() => {
            const updateGradientPosition = () => {
                if (!containerRef.current || !gradientRef.current) return
                const rect = containerRef.current.getBoundingClientRect()
                const mouseX = cursorPosition.current.x - rect.left
                const mouseY = cursorPosition.current.y - rect.top

                gradientRef.current.style.setProperty("--x", `${mouseX}px`)
                gradientRef.current.style.setProperty("--y", `${mouseY}px`)

                requestAnimationFrame(updateGradientPosition)
            }
            updateGradientPosition()
        }, [])

        const gradientBackground = `radial-gradient(circle at var(--x, 20%) var(--y, 20%), ${colors.join(
            ", "
        )})`

        return (
            <Component
                {...props}
                as={motion.div}
                ref={containerRef}
                style={{
                    ...props.style,
                    position: "relative",
                    overflow: "hidden",
                }}
            >
                <motion.div
                    ref={gradientRef}
                    style={{
                        position: "absolute",
                        top: 0,
                        left: 0,
                        width: "100%",
                        height: "100%",
                        background: gradientBackground,
                        mixBlendMode: "overlay",
                        transition: "background-position 0.2s",
                    }}
                    initial={{ scale: 1 }}
                    animate={{ scale: 1 }}
                    exit={{ scale: 0 }}
                    transition={{ duration: 0.4 }}
                />
                {props.children}
            </Component>
        )
    }
}

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.