INFINITYUI
HomeComponentsDocsTemplates
Star

Getting Started

  • Introduction
  • Installation
  • CLI
  • Audit

Navigation

  • Spotlight Navbar
  • Glass DockNEW
  • Animated Tab Bar
  • Circle Menu
  • Magnet Tabs
  • Animated Sidebar
  • Apple Spotlight
  • Page TOC RailNEW

Text

  • Flip Text
  • Glitch Text
  • Liquid Text
  • Flip Fade Text
  • Mask Cursor Effect

Cards

  • Glow Border Card
  • Testimonials Card
  • Interactive Book
  • Trading CardsNEW
  • Hover Image
  • Chain of ThoughtNEW
  • Masonry Grid
  • Image Pile
  • Staggered Grid

Inputs

  • AI InputNEW
  • OTP Input
  • Leave Rating

Buttons

  • Social Flip Button
  • Creepy Button

Loaders

  • Jelly Loader
  • Rolling Ball Scroll
  • Glowing Scroll

Backgrounds

  • Light Lines
  • Perspective Grid
  • Liquid Ocean
  • Eagle Vision
  • Flow Scroll
  • Horizontal Scroll

Overlays

  • PersonaNEW
  • Infinite Moving Cards
  • Masked Avatars
  • Stacked Logos
  • Icon Wheel
  • Pixelated CarouselNEW
  • Pixelated Image Trail
  • Flip Scroll
  • Interactive Folder
  • Animated Folder IconNEW
  • Stack Scroll
  • Rubik Cube
Text

Mask Cursor Effect

#cursor#mask#text-reveal

✦ Move your cursor here to reveal the hidden message beneath ✦

✦ You found it! The magic was here all along ✦

implementedInfinityUI component

This component is fully implemented in InfinityUI and wired into the docs and registry flow.

Installation

Use the registry command to add the component source, and install any package dependencies if needed.

Infinity Registry

Install the component source into your project with the shadcn CLI.

npx shadcn@latest add https://infinityui-pearl.vercel.app/r/mask-cursor-effect
Package Dependencies

Install the npm packages used by this component source.

npm install framer-motion

Component Code

Copy and paste this code into your component file.

tsx
"use client";

import { useRef, useState } from "react";
import { motion, useMotionValue, useSpring } from "framer-motion";

interface MaskCursorEffectProps {
    revealText?: string;
    baseText?: string;
    className?: string;
}

export function MaskCursorEffect({
    revealText = "✦ Hover to reveal the magic beneath the surface ✦",
    baseText = "✦ Move your cursor across the text to see what is hidden ✦",
    className = "",
}: MaskCursorEffectProps) {
    const containerRef = useRef<HTMLDivElement>(null);
    const [active, setActive] = useState(false);
    const rawX = useMotionValue(0);
    const rawY = useMotionValue(0);
    const x = useSpring(rawX, { stiffness: 300, damping: 30 });
    const y = useSpring(rawY, { stiffness: 300, damping: 30 });

    const handleMove = (e: React.MouseEvent<HTMLDivElement>) => {
        const rect = containerRef.current?.getBoundingClientRect();
        if (!rect) return;
        rawX.set(e.clientX - rect.left);
        rawY.set(e.clientY - rect.top);
    };

    return (
        <div
            ref={containerRef}
            onMouseMove={handleMove}
            onMouseEnter={() => setActive(true)}
            onMouseLeave={() => setActive(false)}
            className={`relative overflow-hidden cursor-none select-none ${className}`}
        >
            {/* Base dark layer */}
            <p className="text-zinc-700 text-xl font-bold text-center leading-relaxed px-8 py-12">
                {baseText}
            </p>

            {/* Masked reveal layer */}
            <motion.div
                className="absolute inset-0 flex items-center justify-center"
                style={{
                    WebkitMaskImage: `radial-gradient(circle 100px at ${x.get()}px ${y.get()}px, black 40%, transparent 80%)`,
                    maskImage: `radial-gradient(circle 100px at ${x.get()}px ${y.get()}px, black 40%, transparent 80%)`,
                    opacity: active ? 1 : 0,
                }}
            >
                <p className="text-white text-xl font-bold text-center leading-relaxed px-8 py-12">
                    {revealText}
                </p>
            </motion.div>
        </div>
    );
}