Original by Plinth ยท MIT
Cards
Glass Sheet
A Liquid Glass bottom sheet that springs up over a scene and blurs the water running beneath it.
Install
npx shadcn@latest add https://plinthui.com/r/glass-sheet.json'use client';
import { useRef, useState } from 'react';
// Glass only reads against something behind it โ place this over an image,
// a gradient or busy content; on a plain white background it will look
// nearly invisible. The material (backdrop-filter, a mask-composite rim,
// the pointer-driven highlight) is outside what Tailwind can express, so it
// lives in the embedded style element below.
const css = `
/* ---------- the glass sheet ---------- */
.glass-sheet-demo { position: absolute; inset: 0; }
.glass-sheet__scrim {
position: absolute;
inset: 0;
pointer-events: none;
background: linear-gradient(180deg, rgba(9, 5, 28, 0) 22%, rgba(9, 5, 28, 0.45) 100%);
transition: opacity 420ms ease;
}
.glass-sheet-demo:not(.is-open) .glass-sheet__scrim { opacity: 0; }
.glass-sheet {
position: absolute;
isolation: isolate;
box-sizing: border-box;
left: 14px;
right: 14px;
bottom: 14px;
padding: 11px 17px 15px;
border-radius: 30px;
background: linear-gradient(152deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.09) 46%, rgba(255, 255, 255, 0.2) 100%);
-webkit-backdrop-filter: blur(15px) saturate(205%) brightness(1.1);
backdrop-filter: blur(15px) saturate(205%) brightness(1.1);
box-shadow:
inset 0 1px 1px rgba(255, 255, 255, 0.66),
inset 0 -1px 1px rgba(255, 255, 255, 0.24),
/* the lens lip: light gathering just inside the whole perimeter */
inset 0 0 26px -8px rgba(255, 255, 255, 0.42),
0 -2px 8px rgba(8, 6, 32, 0.2),
0 -14px 34px -14px rgba(8, 6, 32, 0.42),
0 24px 48px -24px rgba(8, 6, 32, 0.55);
translate: 0 0;
transition: translate 560ms cubic-bezier(0.32, 1.3, 0.5, 1);
}
.glass-sheet-demo:not(.is-open) .glass-sheet { translate: 0 calc(100% + 26px); }
/* specular rim: bright where the light lands, gone along the shaded arc */
.glass-sheet::before {
content: "";
position: absolute;
inset: 0;
padding: 1.5px;
border-radius: inherit;
pointer-events: none;
z-index: 3;
background: linear-gradient(
152deg,
rgba(255, 255, 255, 1) 0%,
rgba(255, 255, 255, 0.52) 16%,
rgba(255, 255, 255, 0.06) 42%,
rgba(255, 255, 255, 0.06) 62%,
rgba(255, 255, 255, 0.8) 100%
);
-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
-webkit-mask-composite: xor;
mask-composite: exclude;
}
/* one specular sweep as it arrives */
.glass-sheet::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
pointer-events: none;
z-index: 2;
opacity: 0;
background: linear-gradient(104deg, transparent 36%, rgba(255, 255, 255, 0.4) 50%, transparent 64%);
background-size: 240% 100%;
background-position: 150% 0;
}
.glass-sheet-demo.is-open .glass-sheet::after {
animation: glass-sheet-sweep 1100ms cubic-bezier(0.4, 0, 0.2, 1) 160ms;
}
@keyframes glass-sheet-sweep {
0% { opacity: 0; background-position: 150% 0; }
20% { opacity: 1; }
100% { opacity: 0; background-position: -60% 0; }
}
.glass-sheet__grip {
display: block;
width: 40px;
height: 5px;
margin: 0 auto 10px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.55);
box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.9);
}
.glass-sheet__head {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.glass-sheet__title {
font-size: 16px;
font-weight: 600;
letter-spacing: -0.01em;
color: #fff;
text-shadow: 0 1px 2px rgba(8, 6, 32, 0.34);
}
.glass-sheet__text {
position: relative;
margin-top: 4px;
font-size: 12.5px;
line-height: 1.5;
color: rgba(255, 255, 255, 0.86);
text-shadow: 0 1px 2px rgba(8, 6, 32, 0.34);
}
.glass-sheet__row {
position: relative;
display: flex;
gap: 10px;
margin-top: 12px;
}
.glass-sheet__btn {
flex: 1;
height: 34px;
border: 0;
border-radius: 999px;
font: inherit;
font-size: 13px;
font-weight: 600;
color: #fff;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
background: linear-gradient(150deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.11) 100%);
box-shadow:
inset 0 1px 1px rgba(255, 255, 255, 0.6),
inset 0 -1px 1px rgba(255, 255, 255, 0.2),
0 2px 6px rgba(8, 6, 32, 0.22);
transition: transform 180ms cubic-bezier(0.34, 1.4, 0.5, 1), box-shadow 200ms ease;
}
.glass-sheet__btn--primary {
color: #2a1046;
text-shadow: none;
background: linear-gradient(150deg, rgba(255, 255, 255, 0.94) 0%, rgba(255, 255, 255, 0.7) 100%);
box-shadow:
inset 0 1px 1px rgba(255, 255, 255, 1),
inset 0 -2px 3px rgba(255, 255, 255, 0.7),
0 3px 9px rgba(8, 6, 32, 0.3);
}
.glass-sheet__btn:hover { transform: translateY(-1px); }
.glass-sheet__btn:active { transform: translateY(0) scale(0.975); }
.glass-sheet__close {
display: grid;
place-items: center;
flex: none;
width: 28px;
height: 28px;
border: 0;
border-radius: 999px;
color: #fff;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
background: linear-gradient(150deg, rgba(255, 255, 255, 0.32) 0%, rgba(255, 255, 255, 0.12) 100%);
box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.65), 0 1px 3px rgba(8, 6, 32, 0.24);
}
.glass-sheet__close svg { width: 13px; height: 13px; display: block; }
/* the affordance that brings it back */
.glass-sheet__open {
position: absolute;
left: 50%;
bottom: 20%;
translate: -50% 0;
padding: 11px 22px;
border: 0;
border-radius: 999px;
font: inherit;
font-size: 14px;
font-weight: 600;
color: #fff;
text-shadow: 0 1px 2px rgba(8, 6, 32, 0.4);
cursor: pointer;
-webkit-tap-highlight-color: transparent;
background: linear-gradient(150deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 100%);
-webkit-backdrop-filter: blur(14px) saturate(190%) brightness(1.1);
backdrop-filter: blur(14px) saturate(190%) brightness(1.1);
box-shadow:
inset 0 1px 1px rgba(255, 255, 255, 0.7),
inset 0 -1px 1px rgba(255, 255, 255, 0.26),
0 3px 10px rgba(8, 6, 32, 0.3);
transition: opacity 300ms ease, translate 300ms ease;
}
.glass-sheet-demo.is-open .glass-sheet__open {
opacity: 0;
translate: -50% 10px;
pointer-events: none;
}
.glass-sheet :focus-visible,
.glass-sheet__open:focus-visible {
outline: 2px solid rgba(255, 255, 255, 0.95);
outline-offset: 2px;
}
`;
export function GlassSheet({
title = 'Share this view',
children = 'Anyone with the link can open it.',
defaultOpen = true,
}: {
title?: string;
children?: React.ReactNode;
defaultOpen?: boolean;
}) {
const [open, setOpen] = useState(defaultOpen);
const openerRef = useRef<HTMLButtonElement>(null);
const closerRef = useRef<HTMLButtonElement>(null);
// The panel stays mounted and slides out of frame, so the element to focus
// already exists when the state flips.
const toggle = (next: boolean) => {
setOpen(next);
(next ? closerRef : openerRef).current?.focus({ preventScroll: true });
};
return (
<>
<style>{css}</style>
<div className={open ? 'glass-sheet-demo is-open' : 'glass-sheet-demo'}>
<span className="glass-sheet__scrim" aria-hidden="true" />
<button
ref={openerRef}
type="button"
className="glass-sheet__open"
aria-expanded={open}
aria-controls="glass-sheet-panel"
onClick={() => toggle(true)}
>
Show sheet
</button>
<section
className="glass-sheet"
id="glass-sheet-panel"
role="dialog"
aria-label={title}
>
<span className="glass-sheet__grip" aria-hidden="true" />
<div className="glass-sheet__head">
<h3 className="glass-sheet__title">{title}</h3>
<button
ref={closerRef}
type="button"
className="glass-sheet__close"
aria-label="Close sheet"
onClick={() => toggle(false)}
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2.4"
strokeLinecap="round"
aria-hidden="true"
>
<path d="M6 6l12 12M18 6L6 18" />
</svg>
</button>
</div>
<p className="glass-sheet__text">{children}</p>
<div className="glass-sheet__row">
<button className="glass-sheet__btn" type="button">
Copy link
</button>
<button className="glass-sheet__btn glass-sheet__btn--primary" type="button">
Share
</button>
</div>
</section>
</div>
</>
);
}