NCSS/Motion Engine™
Cursor Glow
A premium, high-performance UI component built with Tailwind CSS and React.
Preview
Installation
Add the required dependencies if you haven't already:
1npm install framer-motion clsx tailwind-merge
Copy and paste the following code into your project:
1"use client";23import { useEffect, useState } from "react";4import { motion, useMotionValue, useSpring } from "framer-motion";56export default function CursorGlow({ children }) {7 const [mounted, setMounted] = useState(false);8 const cursorX = useMotionValue(-100);9 const cursorY = useMotionValue(-100);1011 const springConfig = { damping: 25, stiffness: 200, mass: 0.5 };12 const smoothX = useSpring(cursorX, springConfig);13 const smoothY = useSpring(cursorY, springConfig);1415 useEffect(() => {16 setMounted(true);17 const moveCursor = (e) => {18 cursorX.set(e.clientX - 16); // Center the 32px glow19 cursorY.set(e.clientY - 16);20 };2122 window.addEventListener("mousemove", moveCursor);23 return () => window.removeEventListener("mousemove", moveCursor);24 }, [cursorX, cursorY]);2526 if (!mounted) return null;2728 return (29 <div className="relative w-full h-[400px] bg-[#050505] rounded-2xl overflow-hidden flex flex-col items-center justify-center cursor-none border border-white/5">30 {/* Background elements */}31 <div className="absolute inset-0 bg-[linear-gradient(rgba(255,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(255,255,255,0.02)_1px,transparent_1px)] bg-[size:40px_40px]" />3233 {/* Target area for cursor */}34 <div className="relative z-10 p-12 text-center pointer-events-none">35 <h2 className="text-3xl font-bold text-white tracking-wider mb-2">Cursor Glow</h2>36 <p className="text-gray-400">Move your mouse around this area.</p>37 </div>3839 {/* The Glow Cursor */}40 <motion.div41 className="fixed top-0 left-0 w-8 h-8 rounded-full bg-white mix-blend-difference pointer-events-none z-50"42 style={{43 x: smoothX,44 y: smoothY,45 boxShadow: '0 0 20px 10px rgba(255, 255, 255, 0.5)'46 }}47 />48 </div>49 );50}51