An overlay component that creates a soft, progressive blur effect on content below it, ideal for frosted glass designs.
$ npx shadcn@latest add https://akshitr.com/r/progressive-blur.json
import ProgressiveBlur from "@/components/progressive-blur";
export default function ProgressiveBlurDemo() {
return <ProgressiveBlur />;
}| Prop | Type | Default | Description |
|---|---|---|---|
| className? | string | — | Additional classes applied to the root element. |
| position? | "top/bottom" | "bottom" | Position of the blur effect. |
| height? | string | "12vh" | Height of the blur effect. |
--background CSS variableThe solid-colour overlay at the end of the blur ramp uses hsl(var(--background) / 0.6) via the Tailwind class to-background/60. This variable is defined automatically when you use shadcn/ui — it lives in your globals.css (or index.css) as part of the theme block:
:root {
--background: oklch(1 0 0); /* light mode */
}
.dark {
--background: oklch(0.141 0.005 285.823); /* dark mode */
}If you're not using shadcn/ui, define the variable yourself in your global stylesheet:
:root {
--background: oklch(1 0 0);
}Or swap the Tailwind classes to a hardcoded colour in the component:
// Before (shadcn)
"to-background/60 bg-gradient-to-b from-transparent";
// After (hardcoded)
"bg-gradient-to-b from-transparent to-white/60";
// or dark:
"bg-gradient-to-b from-transparent to-[#09090b]/60";The component won't break without --background — the backdrop-filter layers still work — but the colour overlay will render as transparent, which may look incomplete on sharp blurred backgrounds.