Skip to content

Glass Sheet

Liquid Glass bottom sheet with detents: content peeks around it, and it turns edge-to-edge and more opaque at full height.

  • Liquid Glass
  • Travel & hospitality
  • React only · 0 deps
  • 2 files
Full screen

Browser support · Real refraction (SVG displacement inside backdrop-filter) in Chromium browsers. Safari and Firefox fall back to a frosted blur with the same rim and highlights.

Install. One command, or copy the file.

$npx shadcn@latest add https://freedesignmd.com/r/glass-sheet.json
  • Byte-identical to the preview
  • No Tailwind or config needed
  • SSR-safe · keyboard accessible
  • Respects reduced motion & transparency
components/liquid-glass/glass-sheet.tsx
1/**
2 * GlassSheet, an iOS 26 Liquid Glass sheet with detents.
3 *
4 * - Half / peek detents are inset from the screen edges with a large corner
5 * radius, so content peeks around them (HIG). The radius stays concentric
6 * with the container (`radius` = container radius − inset).
7 * - Drag the grabber (or anywhere on the header) to move between detents;
8 * release uses the drag velocity to pick a detent and springs there.
9 * - At the full detent the sheet grows to the edges, its corners match the
10 * screen and the glass becomes more opaque for long-form reading.
11 *
12 * Props: detents (fractions of the container height, e.g. [0.2, 0.52, 0.94]),
13 * detent (index, controlled) + onDetentChange, inset (px, default 8),
14 * radius (corner radius at rest, default 36), tone, label (aria-label),
15 * header (always-visible content next to the grabber), children (body).
16 * Must be placed inside a positioned container (position: relative), it fills
17 * that container, like a sheet inside a screen.
18 * Keyboard: the grabber is a button, Enter/Space cycles detents, Arrow
19 * Up/Down step through them. role="dialog" aria-modal="false".
20 * Reduced motion: detent changes are instant. Reduced transparency/contrast:
21 * opaque surface.
22 */
23import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
24import type { CSSProperties, KeyboardEvent, ReactNode } from "react";
25import { GlassScope, LiquidGlass, createVelocityTracker, useGlassEnv, useSpring } from "./liquid-glass";
26
27export interface GlassSheetProps {
28 detents?: number[];
29 detent: number;
30 onDetentChange: (i: number) => void;
31 inset?: number;
32 radius?: number;
33 tone?: "light" | "dark";
34 label: string;
35 header?: ReactNode;
36 children?: ReactNode;
37 className?: string;
38}
39
40const useIso = typeof window === "undefined" ? useEffect : useLayoutEffect;
41
42export function GlassSheet({ detents = [0.2, 0.52, 0.94], detent, onDetentChange, inset = 8, radius = 36, tone = "light", label, header, children, className }: GlassSheetProps) {
43 const env = useGlassEnv();
44 const host = useRef<HTMLDivElement | null>(null);
45 const sheet = useRef<HTMLElement | null>(null);
46 const body = useRef<HTMLDivElement | null>(null);
47 const H = useRef(0);
48 const [full, setFull] = useState(false);
49
50 const fullIdx = detents.length - 1;
51 // expansion 0 (inset, glassy) → 1 (edge-to-edge, more opaque) over the last detent interval
52 const paint = (hpx: number) => {
53 const s = sheet.current;
54 const total = H.current;
55 if (!s || !total) return;
56 const lo = detents[Math.max(0, fullIdx - 1)] * total;
57 const hi = detents[fullIdx] * total;
58 const e = Math.min(1, Math.max(0, (hpx - lo) / Math.max(1, hi - lo)));
59 const ins = inset * (1 - e);
60 s.style.height = `${Math.max(56, hpx).toFixed(1)}px`;
61 s.style.left = `${ins.toFixed(2)}px`;
62 s.style.right = `${ins.toFixed(2)}px`;
63 s.style.bottom = `${ins.toFixed(2)}px`;
64 s.style.setProperty("--fd-gsh-e", e.toFixed(3));
65 s.style.borderRadius = `${(radius + inset * e).toFixed(2)}px ${(radius + inset * e).toFixed(2)}px ${(radius * (1 - e) + 0).toFixed(2)}px ${(radius * (1 - e)).toFixed(2)}px`;
66 if (e > 0.98 !== fullRef.current) {
67 fullRef.current = e > 0.98;
68 setFull(fullRef.current);
69 }
70 };
71 const fullRef = useRef(false);
72 const hs = useSpring(0, paint, { stiffness: 380, damping: 34, precision: 0.2 });
73
74 const target = useCallback((i: number) => detents[Math.min(Math.max(i, 0), fullIdx)] * H.current, [detents, fullIdx]);
75
76 // measure container
77 useIso(() => {
78 const h = host.current?.parentElement;
79 if (!h) return;
80 const measure = () => {
81 H.current = h.clientHeight;
82 hs.set(target(detentRef.current));
83 };
84 measure();
85 const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(measure) : null;
86 ro?.observe(h);
87 return () => ro?.disconnect();
88 // eslint-disable-next-line react-hooks/exhaustive-deps
89 }, []);
90 const detentRef = useRef(detent);
91 detentRef.current = detent;
92
93 const dragging = useRef(false);
94 useEffect(() => {
95 if (dragging.current || !H.current) return;
96 hs.stiffness = 380;
97 hs.damping = 34;
98 if (env.reducedMotion) hs.set(target(detent));
99 else hs.to(target(detent));
100 }, [detent, target, env.reducedMotion, hs]);
101
102 // drag on the header zone
103 const grab = useRef<HTMLDivElement | null>(null);
104 useEffect(() => {
105 const g = grab.current;
106 if (!g) return;
107 const vt = createVelocityTracker();
108 let pid = -1, y0 = 0, h0 = 0, moved = false;
109 const down = (e: PointerEvent) => {
110 if (e.button !== 0) return;
111 pid = e.pointerId;
112 y0 = e.clientY;
113 h0 = hs.value;
114 moved = false;
115 vt.reset();
116 vt.push(0, e.clientY);
117 // follow the gesture on window: the finger leaves the grab zone immediately
118 window.addEventListener("pointermove", move);
119 window.addEventListener("pointerup", up);
120 window.addEventListener("pointercancel", up);
121 };
122 const move = (e: PointerEvent) => {
123 if (e.pointerId !== pid) return;
124 const dy = y0 - e.clientY;
125 if (!moved && Math.abs(dy) < 4) return;
126 if (!moved) {
127 moved = true;
128 dragging.current = true;
129 g.classList.add("is-dragging");
130 }
131 vt.push(0, e.clientY);
132 const min = target(0), max = target(fullIdx);
133 let h = h0 + dy;
134 if (h > max) h = max + (h - max) * 0.2;
135 if (h < min) h = min - (min - h) * 0.3;
136 hs.stiffness = 1200;
137 hs.damping = 70;
138 if (env.reducedMotion) hs.set(h);
139 else hs.to(h);
140 };
141 const up = (e: PointerEvent) => {
142 if (e.pointerId !== pid) return;
143 pid = -1;
144 window.removeEventListener("pointermove", move);
145 window.removeEventListener("pointerup", up);
146 window.removeEventListener("pointercancel", up);
147 if (!moved) return;
148 g.classList.remove("is-dragging");
149 dragging.current = false;
150 const { vy } = vt.get();
151 const projected = hs.value - vy * 0.18; // fling
152 let best = 0, bd = Infinity;
153 detents.forEach((d, i) => {
154 const dd = Math.abs(d * H.current - projected);
155 if (dd < bd) (bd = dd), (best = i);
156 });
157 hs.stiffness = 380;
158 hs.damping = 32;
159 if (env.reducedMotion) hs.set(target(best));
160 else hs.to(target(best), -vy);
161 if (best !== detentRef.current) onDetentChange(best);
162 // eat the click that ends a drag
163 const stop = (ev: Event) => {
164 ev.stopPropagation();
165 ev.preventDefault();
166 };
167 g.addEventListener("click", stop, { capture: true, once: true });
168 setTimeout(() => g.removeEventListener("click", stop, { capture: true }), 0);
169 };
170 g.addEventListener("pointerdown", down);
171 return () => {
172 g.removeEventListener("pointerdown", down);
173 window.removeEventListener("pointermove", move);
174 window.removeEventListener("pointerup", up);
175 window.removeEventListener("pointercancel", up);
176 };
177 }, [detents, fullIdx, target, onDetentChange, env.reducedMotion, hs]);
178
179 const onGrabKey = (e: KeyboardEvent<HTMLButtonElement>) => {
180 if (e.key === "ArrowUp") {
181 e.preventDefault();
182 onDetentChange(Math.min(fullIdx, detent + 1));
183 } else if (e.key === "ArrowDown") {
184 e.preventDefault();
185 onDetentChange(Math.max(0, detent - 1));
186 }
187 };
188
189 return (
190 <GlassScope>
191 <div ref={host} className={["fd-gsh-host", `fd-gsh--${tone}`, className ?? ""].filter(Boolean).join(" ")}>
192 <style>{css}</style>
193 <LiquidGlass
194 ref={sheet}
195 className={`fd-gsh${full ? " is-full" : ""}`}
196 variant="regular"
197 tone={tone}
198 radius="auto"
199 bezel={28}
200 role="dialog"
201 aria-modal="false"
202 aria-label={label}
203 style={{ "--fd-gsh-r": `${radius}px` } as CSSProperties}
204 >
205 <div ref={grab} className="fd-gsh-grab">
206 <button
207 type="button"
208 className="fd-gsh-handle"
209 aria-label={`Resize sheet, ${["collapsed", "half height", "full height"][Math.min(detent, 2)] ?? `detent ${detent + 1}`}`}
210 onClick={() => onDetentChange(detent >= fullIdx ? 0 : detent + 1)}
211 onKeyDown={onGrabKey}
212 >
213 <span aria-hidden="true" />
214 </button>
215 {header}
216 </div>
217 <div ref={body} className="fd-gsh-body" aria-hidden={detent === 0 || undefined}>
218 {children}
219 </div>
220 </LiquidGlass>
221 </div>
222 </GlassScope>
223 );
224}
225
226const css = `
227.fd-gsh-host,.fd-gsh-host *,.fd-gsh-host *::before,.fd-gsh-host *::after{box-sizing:border-box}
228.fd-gsh-host{position:absolute;inset:0;margin:0;padding:0;pointer-events:none;z-index:4}
229.fd-gsh{position:absolute !important;left:8px;right:8px;bottom:8px;height:50%;display:flex;flex-direction:column;margin:0;padding:0;overflow:hidden;pointer-events:auto;will-change:height;text-align:left;
230 --fd-lg-shadow:0 -10px 40px -10px rgba(0,0,0,0.28),0 0 0 0.5px rgba(0,0,0,0.04);
231 color:#0B0B0F;font:400 15px/1.4 ui-sans-serif,-apple-system,BlinkMacSystemFont,"SF Pro Text","Inter","Segoe UI",Roboto,sans-serif}
232.fd-gsh--dark .fd-gsh{color:#F2F2F7}
233/* more opaque as it expands: fill alpha .3 → .86 */
234.fd-gsh .fd-lg-fill{background:rgba(250,250,252,calc(0.5 + var(--fd-gsh-e,0) * 0.44))}
235.fd-gsh--dark .fd-gsh .fd-lg-fill{background:rgba(28,28,32,calc(0.5 + var(--fd-gsh-e,0) * 0.42))}
236.fd-gsh-grab{position:relative;flex:none;margin:0;padding:0 20px 8px;touch-action:none;cursor:grab;user-select:none;-webkit-user-select:none}
237.fd-gsh-grab.is-dragging,.fd-gsh-grab.is-dragging *{cursor:grabbing}
238.fd-gsh-handle{display:flex;justify-content:center;align-items:center;width:100%;height:22px;margin:0;padding:0;border:0;background:none;cursor:inherit;-webkit-appearance:none;appearance:none;border-radius:8px}
239.fd-gsh-handle span{display:block;width:38px;height:5px;margin:0;border-radius:3px;background:rgba(11,11,15,0.22)}
240.fd-gsh--dark .fd-gsh-handle span{background:rgba(255,255,255,0.32)}
241.fd-gsh-handle:focus-visible{outline:2px solid color-mix(in srgb,#0A84FF 70%,transparent);outline-offset:-2px}
242.fd-gsh-body{position:relative;flex:1;min-height:0;margin:0;padding:0 20px 24px;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none}
243.fd-gsh-body::-webkit-scrollbar{display:none}
244@media (prefers-reduced-transparency: reduce){.fd-gsh .fd-lg-fill{background:#F2F2F7}.fd-gsh--dark .fd-gsh .fd-lg-fill{background:#1C1C22}}
245@media (prefers-contrast: more){.fd-gsh .fd-lg-fill{background:#fff}.fd-gsh--dark .fd-gsh .fd-lg-fill{background:#000}}
246`;
247
248/* ───────────────────────── demo ───────────────────────── */
249
250const ROWS = [
251 { t: "Directions", d: <path d="M12 3.5 20.5 12 12 20.5 3.5 12 12 3.5ZM9 13v-2.2a1 1 0 0 1 1-1h5m0 0-2-2m2 2-2 2" /> },
252 { t: "Share", d: <path d="M12 3.5v11M8 7l4-3.5L16 7M8.5 10.5H7a1.5 1.5 0 0 0-1.5 1.5v7A1.5 1.5 0 0 0 7 20.5h10a1.5 1.5 0 0 0 1.5-1.5v-7a1.5 1.5 0 0 0-1.5-1.5h-1.5" /> },
253 { t: "Add to favorites", d: <path d="M12 20s-7.5-4.4-7.5-10.1A4.4 4.4 0 0 1 12 7.3a4.4 4.4 0 0 1 7.5 2.6C19.5 15.6 12 20 12 20Z" /> },
254];
255
256export function Demo() {
257 const [detent, setDetent] = useState(1);
258 return (
259 <div className="fd-gshd">
260 <style>{demoCss}</style>
261 <div className="fd-gshd-stage">
262 <GlassSheet
263 detent={detent}
264 onDetentChange={setDetent}
265 label="Place details"
266 header={
267 <div className="fd-gshd-head">
268 <p className="fd-gshd-title">Harbour View</p>
269 <p className="fd-gshd-sub">Lisbon, Portugal</p>
270 </div>
271 }
272 >
273 <ul className="fd-gshd-list">
274 {ROWS.map((r) => (
275 <li key={r.t} className="fd-gshd-item">
276 <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.9" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
277 {r.d}
278 </svg>
279 <span>{r.t}</span>
280 </li>
281 ))}
282 </ul>
283 </GlassSheet>
284 </div>
285 </div>
286 );
287}
288
289const F = `ui-sans-serif,-apple-system,BlinkMacSystemFont,"SF Pro Text","Inter","Segoe UI",Roboto,sans-serif`;
290
291const demoCss = `
292.fd-gshd,.fd-gshd *,.fd-gshd *::before,.fd-gshd *::after{box-sizing:border-box}
293.fd-gshd{display:flex;align-items:center;justify-content:center;min-height:100vh;width:100%;margin:0;padding:32px 20px;overflow:hidden;color:#1d1d1f;font:400 15px/1.4 ${F};letter-spacing:normal;
294 background:radial-gradient(46% 62% at 28% 32%,#ffcfa6 0%,transparent 70%),radial-gradient(44% 58% at 74% 68%,#b7c3ff 0%,transparent 70%),radial-gradient(30% 40% at 62% 22%,#ffc2dc 0%,transparent 70%),#f1eeea}
295.fd-gshd-stage{position:relative;width:min(100%,360px);height:min(560px,calc(100vh - 64px));margin:0;padding:0}
296.fd-gshd-head{margin:0;padding:6px 0 12px}
297.fd-gshd-title{margin:0;font:700 20px/1.25 ${F};letter-spacing:-0.02em;color:#1d1d1f}
298.fd-gshd-sub{margin:2px 0 0;font:400 14px/1.35 ${F};color:#6e6e73}
299.fd-gshd-list{list-style:none;margin:0;padding:0}
300.fd-gshd-item{display:flex;align-items:center;gap:14px;margin:0;padding:15px 2px;font:500 16px/1.3 ${F};letter-spacing:-0.01em;color:#1d1d1f;border-top:0.5px solid rgba(60,60,67,0.18)}
301.fd-gshd-item svg{display:block;flex:none;color:#0a84ff}
302.fd-gshd-item span{display:block;margin:0;padding:0}
303`;

More Liquid Glass. Same file contract.

Liquid Glass, liquid glass preview: Liquid Glass for React: a lens that refracts what is behind it, with squircle bevel, specular rim, dispersion…

Liquid Glass

Liquid Glass for React: a lens that refracts what is behind it, with squircle bevel, specular rim, dispersion and spring physics.

Glass Button, liquid glass preview: Liquid Glass button for React: glass, prominent, clear and clear-prominent capsules in four sizes, with a…

Glass Button

Liquid Glass button for React: glass, prominent, clear and clear-prominent capsules in four sizes, with a springy press.

Glass Tab Bar, liquid glass preview: iOS 26 style Liquid Glass tab bar: a lens springs between tabs, search sits apart, and the bar minimizes as…

Glass Tab Bar

iOS 26 style Liquid Glass tab bar: a lens springs between tabs, search sits apart, and the bar minimizes as you scroll.

Questions about Glass Sheet

Run npx shadcn@latest add https://freedesignmd.com/r/glass-sheet.json, or open the page and copy the files into your project. It has zero dependencies besides React. What you copy is the exact file that renders the live demo.

Liquid Glass bottom sheet with detents: content peeks around it, and it turns edge-to-edge and more opaque at full height. It is a free, MIT-licensed React liquid glass component from the freedesignmd library.

Yes. It is free and MIT-licensed, use, modify and ship it in personal and commercial projects without attribution.

Real refraction (SVG displacement inside backdrop-filter) in Chromium browsers. Safari and Firefox fall back to a frosted blur with the same rim and highlights.

Yes. It is a plain React component with its own styles, so it runs in Next.js, Vite, Remix and Lovable projects, and it needs no Tailwind setup. It has zero dependencies besides React.