{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"glassmorphism-card-css-with-frosted-navbar-login-panel-and-stat-chips-over-a-photo","type":"registry:block","title":"Glassmorphism Card CSS with Frosted Navbar, Login Panel and Stat Chips over a Photo","description":"Free glassmorphism CSS in React and Tailwind: a frosted glass card, glass navbar, login panel and stat chips over a photo, with a solid fallback built in.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/glassmorphism-card-css-with-frosted-navbar-login-panel-and-stat-chips-over-a-photo.tsx","type":"registry:component","content":"import { useState } from \"react\";\nimport { motion, useReducedMotion } from \"framer-motion\";\n\n// The photo behind the glass. Glass only reads as glass over something with colour and detail.\nconst PHOTO = \"https://images.pexels.com/photos/11143817/pexels-photo-11143817.jpeg?auto=compress&cs=tinysrgb&w=1600\";\n\n// Three strengths of frost. Each sets the blur, the tint and the edge through CSS variables.\nconst FROSTS = {\n  light: { label: \"Light\", blur: \"10px\", tint: \"0.10\", edge: \"0.28\" },\n  medium: { label: \"Medium\", blur: \"18px\", tint: \"0.16\", edge: \"0.34\" },\n  heavy: { label: \"Heavy\", blur: \"30px\", tint: \"0.24\", edge: \"0.42\" },\n} as const;\ntype Frost = keyof typeof FROSTS;\n\nconst links = [\"Trips\", \"Cabins\", \"Guides\", \"Journal\"];\nconst stats = [\n  { label: \"Water\", value: \"11°C\" },\n  { label: \"Wind\", value: \"6 km/h\" },\n  { label: \"Sunset\", value: \"21:48\" },\n];\n\n// The glass recipe. Copy this block into your own stylesheet.\nconst CSS = `\n.s2g-glass {\n  background: rgba(255, 255, 255, var(--s2g-tint, 0.16));\n  -webkit-backdrop-filter: blur(var(--s2g-blur, 18px)) saturate(160%);\n  backdrop-filter: blur(var(--s2g-blur, 18px)) saturate(160%);\n  border: 1px solid rgba(255, 255, 255, var(--s2g-edge, 0.34));\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 12px 40px -12px rgba(15, 10, 5, 0.45);\n}\n.s2g-glass-dark {\n  background: rgba(20, 16, 14, calc(var(--s2g-tint, 0.16) + 0.22));\n  -webkit-backdrop-filter: blur(var(--s2g-blur, 18px)) saturate(140%);\n  backdrop-filter: blur(var(--s2g-blur, 18px)) saturate(140%);\n  border: 1px solid rgba(255, 255, 255, 0.14);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 12px 40px -12px rgba(0, 0, 0, 0.5);\n}\n/* No backdrop-filter support (or the preview switch is on): solid panels that stay readable. */\n@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {\n  .s2g-glass { background: rgba(58, 44, 38, 0.92); }\n  .s2g-glass-dark { background: rgba(24, 20, 18, 0.94); }\n}\n.s2g-nofilter .s2g-glass { background: rgba(58, 44, 38, 0.92); -webkit-backdrop-filter: none; backdrop-filter: none; }\n.s2g-nofilter .s2g-glass-dark { background: rgba(24, 20, 18, 0.94); -webkit-backdrop-filter: none; backdrop-filter: none; }\n`;\n\nconst ring = \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-offset-2 focus-visible:ring-offset-stone-900\";\n\nfunction GlassNavbar() {\n  const [active, setActive] = useState(\"Trips\");\n  return (\n    <nav aria-label=\"Main\" className=\"s2g-glass flex items-center justify-between gap-3 rounded-full py-2 pl-5 pr-2 text-white\">\n      <a href=\"#\" className={`rounded-full text-[15px] font-semibold tracking-tight ${ring}`}>Fjordline</a>\n      <ul className=\"hidden items-center gap-1 sm:flex\">\n        {links.map((l) => (\n          <li key={l}>\n            <a\n              href=\"#\"\n              aria-current={active === l ? \"page\" : undefined}\n              onClick={(e) => { e.preventDefault(); setActive(l); }}\n              className={`inline-flex h-10 items-center rounded-full px-4 text-sm transition-colors ${active === l ? \"bg-white/25 font-medium\" : \"text-white/85 hover:bg-white/10\"} ${ring}`}\n            >\n              {l}\n            </a>\n          </li>\n        ))}\n      </ul>\n      <a href=\"#\" className={`inline-flex h-10 items-center rounded-full bg-white px-4 text-sm font-semibold text-stone-900 hover:bg-white/90 ${ring}`}>Book a cabin</a>\n    </nav>\n  );\n}\n\nfunction GlassCard() {\n  return (\n    <article className=\"s2g-glass rounded-3xl p-6 text-white\">\n      <p className=\"text-xs font-medium uppercase tracking-[0.14em] text-white/80\">Frosted card</p>\n      <h2 className=\"mt-3 text-2xl font-semibold tracking-tight\">Lakeshore cabin, three nights</h2>\n      <p className=\"mt-2 text-sm leading-relaxed text-white/85\">A timber cabin on the north shore with a wood stove, a rowing boat and the ridge line out of every window.</p>\n      <div className=\"mt-6 flex items-end justify-between gap-4\">\n        <p><span className=\"text-3xl font-semibold tracking-tight\">€420</span><span className=\"ml-1 text-sm text-white/80\">total</span></p>\n        <a href=\"#\" className={`inline-flex h-11 items-center rounded-xl border border-white/40 px-4 text-sm font-medium hover:bg-white/15 ${ring}`}>See dates</a>\n      </div>\n    </article>\n  );\n}\n\nfunction GlassLogin() {\n  return (\n    <form className=\"s2g-glass-dark rounded-3xl p-6 text-white\" onSubmit={(e) => e.preventDefault()} aria-labelledby=\"s2g-login-title\">\n      <h2 id=\"s2g-login-title\" className=\"text-xl font-semibold tracking-tight\">Sign in to your trips</h2>\n      <p className=\"mt-1 text-sm text-white/75\">Glass login panel, darker tint for form contrast.</p>\n      <label htmlFor=\"s2g-email\" className=\"mt-5 block text-sm font-medium\">Email</label>\n      <input id=\"s2g-email\" type=\"email\" autoComplete=\"email\" placeholder=\"you@mail.example\"\n        className=\"mt-1.5 h-11 w-full rounded-xl border border-white/20 bg-white/10 px-3 text-sm text-white placeholder:text-white/55 focus:border-white/60 focus:outline-none focus:ring-2 focus:ring-white/40\" />\n      <label htmlFor=\"s2g-pass\" className=\"mt-4 block text-sm font-medium\">Password</label>\n      <input id=\"s2g-pass\" type=\"password\" autoComplete=\"current-password\"\n        className=\"mt-1.5 h-11 w-full rounded-xl border border-white/20 bg-white/10 px-3 text-sm text-white focus:border-white/60 focus:outline-none focus:ring-2 focus:ring-white/40\" />\n      <button type=\"submit\" className={`mt-5 h-11 w-full rounded-xl bg-white text-sm font-semibold text-stone-900 hover:bg-white/90 ${ring}`}>Sign in</button>\n    </form>\n  );\n}\n\nfunction StatChips() {\n  return (\n    <ul className=\"flex flex-wrap gap-2\" aria-label=\"Conditions tonight\">\n      {stats.map((s) => (\n        <li key={s.label} className=\"s2g-glass inline-flex h-10 items-center gap-2 rounded-full px-4 text-sm text-white\">\n          <span className=\"text-white/80\">{s.label}</span>\n          <span className=\"font-semibold tabular-nums\">{s.value}</span>\n        </li>\n      ))}\n    </ul>\n  );\n}\n\nexport default function GlassmorphismSet() {\n  const reduce = useReducedMotion();\n  const [frost, setFrost] = useState<Frost>(\"medium\");\n  const [noFilter, setNoFilter] = useState(false);\n  const f = FROSTS[frost];\n  const enter = (i: number) => ({\n    initial: reduce ? false : { opacity: 0, y: 14 },\n    animate: { opacity: 1, y: 0 },\n    transition: { type: \"spring\", stiffness: 260, damping: 28, delay: reduce ? 0 : 0.08 * i },\n  } as const);\n\n  return (\n    <section\n      className={`relative min-h-[680px] overflow-hidden bg-stone-800 font-[Inter_Tight,Inter,ui-sans-serif,system-ui] ${noFilter ? \"s2g-nofilter\" : \"\"}`}\n      style={{ [\"--s2g-blur\" as string]: f.blur, [\"--s2g-tint\" as string]: f.tint, [\"--s2g-edge\" as string]: f.edge }}\n    >\n      <style>{CSS}</style>\n      <img src={PHOTO} alt=\"Mountain lake at sunset with a dark rock in the still water\" width={1600} height={1066}\n        className=\"absolute inset-0 h-full w-full object-cover motion-safe:animate-[s2g-drift_24s_ease-in-out_infinite_alternate]\" />\n      <style>{`@keyframes s2g-drift { from { transform: scale(1.04) translateX(0); } to { transform: scale(1.08) translateX(-1.5%); } }`}</style>\n      <div className=\"absolute inset-0 bg-gradient-to-b from-stone-900/45 via-stone-900/5 to-stone-900/40\" aria-hidden=\"true\" />\n\n      <div className=\"relative mx-auto flex min-h-[680px] max-w-5xl flex-col justify-between gap-6 px-4 py-6 sm:px-6 sm:py-10\">\n        <motion.div {...enter(0)}><GlassNavbar /></motion.div>\n\n        <div className=\"grid gap-6 md:grid-cols-[1.15fr_1fr] md:items-end md:pb-6\">\n          <div className=\"flex flex-col gap-5\">\n            <motion.div {...enter(1)}><GlassCard /></motion.div>\n            <motion.div {...enter(2)}><StatChips /></motion.div>\n            <motion.div {...enter(3)} className=\"s2g-glass-dark flex flex-wrap items-center gap-3 rounded-2xl p-3 text-white\">\n              <div role=\"radiogroup\" aria-label=\"Frost strength\" className=\"flex rounded-full bg-white/10 p-1\">\n                {(Object.keys(FROSTS) as Frost[]).map((k) => (\n                  <button key={k} type=\"button\" role=\"radio\" aria-checked={frost === k} onClick={() => setFrost(k)}\n                    className={`h-9 rounded-full px-3.5 text-sm transition-colors ${frost === k ? \"bg-white font-semibold text-stone-900\" : \"text-white/85 hover:bg-white/10\"} ${ring}`}>\n                    {FROSTS[k].label}\n                  </button>\n                ))}\n              </div>\n              <button type=\"button\" role=\"switch\" aria-checked={noFilter} onClick={() => setNoFilter((v) => !v)}\n                className={`inline-flex h-10 items-center gap-2 rounded-full px-3 text-sm text-white/90 hover:bg-white/10 ${ring}`}>\n                <span aria-hidden=\"true\" className={`relative inline-block h-5 w-9 shrink-0 rounded-full transition-colors ${noFilter ? \"bg-white\" : \"bg-white/25\"}`}>\n                  <span className={`absolute left-0 top-0.5 h-4 w-4 rounded-full transition-transform ${noFilter ? \"translate-x-[18px] bg-stone-900\" : \"translate-x-0.5 bg-white/90\"}`} />\n                </span>\n                Preview fallback\n              </button>\n            </motion.div>\n          </div>\n          <motion.div {...enter(2)}><GlassLogin /></motion.div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
