Glass Button
Liquid Glass button for React: glass, prominent, clear and clear-prominent capsules in four sizes, with a springy press.
- Liquid Glass
- Travel & hospitality
- React only · 0 deps
- 2 files
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-button.json- Byte-identical to the preview
- No Tailwind or config needed
- SSR-safe · keyboard accessible
- Respects reduced motion & transparency
components/liquid-glass/glass-button.tsx
1/**2 * GlassButton, Liquid Glass buttons from Apple's HIG.3 *4 * Styles: "glass" regular glass, neutral (secondary actions)5 * "glassProminent" glass tinted with the accent (the primary action)6 * "clear" clear glass for photos/video (+ `dim` over bright media)7 * "clearProminent" clear glass with accent tint8 * Sizes: "s" 32 · "m" 40 · "l" 48 · "xl" 60 (capsules; icon-only buttons are circles)9 *10 * Props: glass, size, tone ("light" | "dark", regular glass only), tint (accent,11 * default #007AFF), icon (leading icon node), iconOnly (requires aria-label),12 * dim, plus every native <button> attribute.13 * Wrap many buttons in <GlassScope> (from ./liquid-glass) to render the14 * stylesheets once.15 *16 * Behaviour: press scales to 0.96 and releases with a spring overshoot, and a17 * soft glow blooms from the touch point (keyboard: from the centre).18 * Browser support: real refraction in Chromium; frosted fallback elsewhere19 * (see ./liquid-glass). Accessibility: native <button>, visible focus ring,20 * disabled uses the native attribute. Icon-only buttons must get aria-label.21 */22import { forwardRef } from "react";23import type { ButtonHTMLAttributes, CSSProperties, ReactNode } from "react";24import { GlassScope, LiquidGlass } from "./liquid-glass";25 26export type GlassButtonStyle = "glass" | "glassProminent" | "clear" | "clearProminent";27export type GlassButtonSize = "s" | "m" | "l" | "xl";28 29export interface GlassButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {30 glass?: GlassButtonStyle;31 size?: GlassButtonSize;32 tone?: "light" | "dark";33 /** Accent used by the prominent styles. */34 tint?: string;35 icon?: ReactNode;36 iconOnly?: boolean;37 /** Clear styles: 35% dimming layer for bright backgrounds. */38 dim?: boolean;39}40 41const HEIGHT: Record<GlassButtonSize, number> = { s: 32, m: 40, l: 48, xl: 60 };42 43export const GlassButton = forwardRef<HTMLButtonElement, GlassButtonProps>(function GlassButton(44 { glass = "glass", size = "m", tone = "light", tint = "#007AFF", icon, iconOnly = false, dim = false, className, style, children, type = "button", ...rest },45 ref,46) {47 const clear = glass === "clear" || glass === "clearProminent";48 const prominent = glass === "glassProminent" || glass === "clearProminent";49 const h = HEIGHT[size];50 return (51 <LiquidGlass52 ref={ref as never}53 as="button"54 type={type}55 variant={clear ? "clear" : "regular"}56 tone={tone}57 tint={prominent ? tint : undefined}58 dim={clear && dim && !prominent}59 interactive60 className={["fd-gbtn", `fd-gbtn--${size}`, iconOnly ? "fd-gbtn--icon" : "", prominent ? "fd-gbtn--prominent" : "", className ?? ""].filter(Boolean).join(" ")}61 style={{ "--fd-gbtn-h": `${h}px`, ...style } as CSSProperties}62 {...rest}63 >64 <style>{css}</style>65 {icon ? (66 <span className="fd-gbtn-icon" aria-hidden="true">67 {icon}68 </span>69 ) : null}70 {!iconOnly && children != null ? <span className="fd-gbtn-label">{children}</span> : null}71 </LiquidGlass>72 );73});74 75const css = `76.fd-gbtn{display:inline-flex;align-items:center;justify-content:center;gap:8px;flex:none;height:var(--fd-gbtn-h);min-width:var(--fd-gbtn-h);margin:0;padding:0 calc(var(--fd-gbtn-h) * 0.42);vertical-align:middle;white-space:nowrap;user-select:none;-webkit-user-select:none;77 font:600 15px/1 ui-sans-serif,-apple-system,BlinkMacSystemFont,"SF Pro Text","Inter","Segoe UI",Roboto,sans-serif;letter-spacing:-0.01em;text-align:center}78.fd-gbtn--s{font-size:13px;gap:6px}79.fd-gbtn--l{font-size:17px}80.fd-gbtn--xl{font-size:20px;gap:10px;font-weight:600}81.fd-gbtn--icon{width:var(--fd-gbtn-h);padding:0}82.fd-gbtn-icon{display:inline-flex;align-items:center;justify-content:center;margin:0;padding:0;color:inherit}83.fd-gbtn-icon svg{display:block;width:calc(var(--fd-gbtn-h) * 0.46);height:calc(var(--fd-gbtn-h) * 0.46)}84.fd-gbtn:not(.fd-gbtn--icon) .fd-gbtn-icon svg{width:calc(var(--fd-gbtn-h) * 0.42);height:calc(var(--fd-gbtn-h) * 0.42);margin-left:-2px}85.fd-gbtn-label{display:block;margin:0;padding:0;color:inherit;font:inherit;letter-spacing:inherit}86.fd-gbtn:disabled{opacity:0.42;cursor:default}87.fd-gbtn:disabled .fd-lg-glow{display:none}88`;89 90/* ───────────────────────── demo: booking actions ───────────────────────── */91 92const I = {93 back: <path d="M14.5 4.5 7 12l7.5 7.5" />,94 share: (95 <>96 <path d="M12 3.5v11" />97 <path d="m8 7 4-3.5L16 7" />98 <path d="M8.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 17 10.5h-1.5" />99 </>100 ),101 heart: <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" />,102 grid: (103 <>104 <rect x="4" y="4" width="6.5" height="6.5" rx="1.6" />105 <rect x="13.5" y="4" width="6.5" height="6.5" rx="1.6" />106 <rect x="4" y="13.5" width="6.5" height="6.5" rx="1.6" />107 <rect x="13.5" y="13.5" width="6.5" height="6.5" rx="1.6" />108 </>109 ),110 calendar: (111 <>112 <rect x="4" y="5.5" width="16" height="14.5" rx="3" />113 <path d="M4 10h16M8.5 3.5v4M15.5 3.5v4" />114 </>115 ),116 play: <path d="M8 5.8v12.4a.8.8 0 0 0 1.2.7l10-6.2a.8.8 0 0 0 0-1.4l-10-6.2A.8.8 0 0 0 8 5.8Z" fill="currentColor" stroke="none" />,117 plus: <path d="M12 5v14M5 12h14" />,118 more: (119 <>120 <circle cx="6" cy="12" r="1.6" fill="currentColor" stroke="none" />121 <circle cx="12" cy="12" r="1.6" fill="currentColor" stroke="none" />122 <circle cx="18" cy="12" r="1.6" fill="currentColor" stroke="none" />123 </>124 ),125};126const Icon = ({ d }: { d: ReactNode }) => (127 <svg aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">128 {d}129 </svg>130);131 132export function Demo() {133 return (134 <div className="fd-gbd">135 <style>{demoCss}</style>136 <GlassScope>137 <div className="fd-gbd-row">138 <GlassButton glass="glass" size="l" icon={<Icon d={I.grid} />}>Glass</GlassButton>139 <GlassButton glass="glassProminent" size="l" icon={<Icon d={I.calendar} />}>Prominent</GlassButton>140 <GlassButton glass="glass" size="l" iconOnly aria-label="Play" icon={<Icon d={I.play} />} />141 <GlassButton glass="glass" size="l" iconOnly aria-label="More options" icon={<Icon d={I.more} />} />142 </div>143 </GlassScope>144 </div>145 );146}147 148const F = `ui-sans-serif,-apple-system,BlinkMacSystemFont,"SF Pro Text","Inter","Segoe UI",Roboto,sans-serif`;149 150const demoCss = `151.fd-gbd,.fd-gbd *,.fd-gbd *::before,.fd-gbd *::after{box-sizing:border-box}152.fd-gbd{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;153 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}154.fd-gbd-row{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:14px;margin:0;padding:0}155`;More Liquid Glass. Same file contract.
Questions about Glass Button
Run npx shadcn@latest add https://freedesignmd.com/r/glass-button.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 button for React: glass, prominent, clear and clear-prominent capsules in four sizes, with a springy press. 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.


