Created
June 14, 2025 07:41
-
-
Save mnixry/201540af1e1f2c934a86ef7e3e785a23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { cn } from "@/utils"; | |
export const ProgressiveBlurBackground: React.FC< | |
React.ComponentProps<"div"> & { | |
orientation?: "top" | "bottom"; | |
steps?: number; | |
blurTargetPx?: number; | |
} | |
> = ({ | |
className, | |
orientation = "top", | |
steps = 7, | |
blurTargetPx = steps, | |
...props | |
}) => { | |
return ( | |
<div | |
className={cn("absolute inset-0 pointer-events-none -z-5", className)} | |
{...props} | |
> | |
{Array.from({ length: steps }).map((_, index) => ( | |
<div | |
key={index} | |
className={cn( | |
"absolute w-full h-(--height) backdrop-blur-(--bg-blur)", | |
{ | |
"bottom-(--position) mask-t-from-50%": orientation === "bottom", | |
"top-(--position) mask-b-from-50%": orientation === "top", | |
}, | |
)} | |
style={ | |
{ | |
"--bg-blur": `${((index + 1) / blurTargetPx) * steps}px`, | |
"--position": `${ | |
orientation === "top" | |
? 100 - (100 / steps) * index | |
: (100 / steps) * index | |
}%`, | |
"--height": `${(100 / steps) * 2}%`, | |
} as React.CSSProperties | |
} | |
/> | |
))} | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment