Docs
Fuzzy Overlay
A fuzzy overlay is a soft, blurred layer applied over content to create depth, focus attention, or enhance readability while maintaining a subtle aesthetic.
Installation
Install dependencies
npm install framer-motion lucide-react
Run the following command
It will create a new file fuzzy-overlay.tsx
inside the components/mage-ui/background
directory.
mkdir -p components/mage-ui/background && touch components/mage-ui/background/fuzzy-overlay.tsx
Paste the code
Open the newly created file and paste the following code:
"use client";
import React from "react";
import { motion } from "framer-motion";
const FuzzyOverlayExample: React.FC = () => {
return (
// NOTE: An overflow of hidden will be required on a wrapping
// element to see expected results
<div className="relative overflow-hidden">
<ExampleContent />
<FuzzyOverlay />
</div>
);
};
const FuzzyOverlay: React.FC = () => {
return (
<motion.div
initial={{ transform: "translateX(-10%) translateY(-10%)" }}
animate={{
transform: "translateX(10%) translateY(10%)",
}}
transition={{
repeat: Infinity,
duration: 0.2,
ease: "linear",
repeatType: "mirror",
}}
// You can download these PNGs here:
// https://www.hover.dev/black-noise.png
// https://www.hover.dev/noise.png
style={{
backgroundImage: 'url("https://images.unsplash.com/photo-1602475063211-3d98d60e3b1f?q=80&w=2157&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D")',
// backgroundImage: 'url("/noise.png")',
}}
className="pointer-events-none absolute -inset-[100%] opacity-[15%]"
/>
);
};
const ExampleContent: React.FC = () => {
return (
<div className="relative grid h-screen place-content-center space-y-6 bg-neutral-950 p-8">
<p className="text-center text-6xl font-black text-neutral-50">
Fuzzy Overlay Example
</p>
<p className="text-center text-neutral-400">
This is a basic example of using a lo-fi fuzzy overlay 📺
</p>
<div className="flex items-center justify-center gap-3">
<button className="text-neutral-20 w-fit px-4 py-2 font-semibold text-neutral-200 transition-colors hover:bg-neutral-800">
Pricing
</button>
<button className="w-fit bg-neutral-200 px-4 py-2 font-semibold text-neutral-700 transition-colors hover:bg-neutral-50">
Try it free
</button>
</div>
</div>
);
};
export default FuzzyOverlayExample;