Cards
GlassFrame
Frosted glass over whatever sits behind it. A sheen passes across on hover. Needs colour behind it to show.
Download
- React
- Tailwind CSS v4
components/ui/glass-frame.tsx
import type { ReactNode } from "react";
type GlassFrameProps = {
children: ReactNode;
className?: string;
/** Blur of what sits behind the card, in pixels. */
blur?: number;
/** Glass colour. Keep it see-through. */
tint?: string;
};
/* GlassFrame: frosted glass over whatever is behind it. A sheen passes across on hover. */
export function GlassFrame({
children,
className = "rounded-2xl p-6 text-white",
blur = 16,
tint = "rgba(255,255,255,0.08)",
}: GlassFrameProps) {
const filter = `blur(${blur}px) saturate(1.4)`;
return (
<div
className={`group relative overflow-hidden ${className}`}
style={{
background: tint,
backdropFilter: filter,
WebkitBackdropFilter: filter,
boxShadow:
"inset 0 1px 0 rgba(255,255,255,0.25), inset 0 0 0 1px rgba(255,255,255,0.12), 0 24px 48px -24px rgba(0,0,0,0.6)",
}}
>
<span
aria-hidden
className="pointer-events-none absolute inset-y-0 -left-1/2 w-1/2 -skew-x-12 bg-gradient-to-r from-transparent via-white/20 to-transparent opacity-0 transition-[translate,opacity] duration-700 ease-out group-hover:translate-x-[320%] group-hover:opacity-100 motion-reduce:hidden"
/>
<div className="relative">{children}</div>
</div>
);
}
1. Paste the Code tab into
components/ui/glass-frame.tsx. The styles are Tailwind CSS v4 classes.2. Use it. This is the preview above:
app/glass-frame-demo.tsx
import { GlassFrame } from "@/components/ui/glass-frame"; export default function GlassFrameExample() { return ( <div className="relative grid h-full place-items-center overflow-hidden bg-[#0b0a14] p-6"> <div aria-hidden className="absolute left-[18%] top-[18%] size-40 rounded-full bg-[#a78bfa]" /> <div aria-hidden className="absolute bottom-[14%] right-[20%] size-32 rounded-full bg-[#38bdf8]" /> <GlassFrame className="w-full max-w-[300px] rounded-2xl p-6 text-white"> <p className="font-mono text-[11px] uppercase tracking-[0.2em] text-white/70">Now playing</p> <p className="mt-3 text-2xl font-semibold">Midnight Drive</p> <p className="mt-2 text-sm text-white/70">Hover to catch the sheen.</p> </GlassFrame> </div> ); }
Props
| Name | Type | Default | What it does |
|---|---|---|---|
| children | ReactNode | — | Card content. |
| blur | number | 16 | Blur of what is behind, in pixels. |
| tint | string | "rgba(255,255,255,0.08)" | Glass colour. Keep it see-through. |
| className | string | "rounded-2xl p-6 text-white" | Shape, padding, text colour. |