{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"frosted-glass","type":"registry:ui","title":"FrostedGlass","description":"Frosted glass surface with organic turbulence-noise refraction, an alternative to LiquidGlass","author":"fancy-ui <https://fancy-ui.rama.app>","categories":["effects"],"registryDependencies":["https://fancy-ui.rama.app/r/internals.json","https://fancy-ui.rama.app/r/internals-dom.json","https://fancy-ui.rama.app/r/utils.json"],"files":[{"path":"react/src/components/frosted-glass/FrostedGlass.tsx","content":"\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport type { CSSProperties, ReactNode } from \"react\";\n\nimport { cn } from \"../../utils\";\nimport { uid } from \"../../internals/use-id\";\nimport \"./frosted-glass.css\";\n\n/**\n * FrostedGlass - frosted glass surface with an organic, wavy refraction of\n * whatever sits behind it.\n *\n * Four layers stack inside a rounded container:\n *\n * 1. Filter layer - `backdrop-filter: blur(0)` pulls the backdrop into this\n *    element's own rendering, then `filter: url(#...)` pointing at the inline\n *    SVG filter distorts it (`feTurbulence` -> `feGaussianBlur` ->\n *    `feDisplacementMap`).\n * 2. Overlay - translucent tint (`tint`).\n * 3. Specular - inset highlights simulating a lit glass rim (`highlight`).\n * 4. Content - the children.\n *\n * An optional conic-gradient border (`border`) frames the container.\n */\nexport interface FrostedGlassProps {\n\t/** Border radius in pixels */\n\tradius?: number;\n\t/** Turbulence noise frequency (lower = wider waves) */\n\tbaseFrequency?: number;\n\t/** Turbulence octaves (detail of the noise) */\n\tnumOctaves?: number;\n\t/** Turbulence random seed */\n\tseed?: number;\n\t/** Gaussian blur softening the noise before displacement */\n\tnoiseBlur?: number;\n\t/** Displacement intensity */\n\tscale?: number;\n\t/** Overlay tint color */\n\ttint?: string;\n\t/** Specular rim highlight color */\n\thighlight?: string;\n\t/** Show the conic-gradient glass border */\n\tborder?: boolean;\n\t/** Backdrop blur (px) for the WebKit fallback */\n\tfallbackBlur?: number;\n\t/** Backdrop saturation (%) for the WebKit fallback */\n\tfallbackSaturation?: number;\n\t/** CSS classes for the content layer */\n\tclassName?: string;\n\t/** CSS classes for the outer container */\n\tcontainerClass?: string;\n\t/** Content rendered on top of the glass */\n\tchildren?: ReactNode;\n}\n\nexport function FrostedGlass({\n\tradius = 24,\n\tbaseFrequency = 0.008,\n\tnumOctaves = 2,\n\tseed = 92,\n\tnoiseBlur = 2,\n\tscale = 70,\n\ttint = \"hsla(0, 0%, 100%, 0.25)\",\n\thighlight = \"hsla(0, 0%, 100%, 0.75)\",\n\tborder = true,\n\tfallbackBlur = 20,\n\tfallbackSaturation = 180,\n\tclassName = \"\",\n\tcontainerClass = \"\",\n\tchildren,\n}: FrostedGlassProps) {\n\t// The filter id is minted after mount, exactly as the Svelte source does:\n\t// the SVG filter and the layer referencing it are absent from the server\n\t// HTML and appear on the first client effect. `uid()` replaces the source's\n\t// `Math.random()` suffix - a monotonic counter cannot collide, and it keeps\n\t// the id ASCII-clean for the `url(#...)` reference below.\n\tconst [filterId, setFilterId] = useState(\"\");\n\n\tuseEffect(() => {\n\t\tsetFilterId(uid(\"fg-dist\"));\n\t}, []);\n\n\tconst containerStyle = {\n\t\tborderRadius: `${radius}px`,\n\t\t\"--fg-tint\": tint,\n\t\t\"--fg-highlight\": highlight,\n\t\t\"--fg-fallback-blur\": `${fallbackBlur}px`,\n\t\t\"--fg-fallback-saturation\": `${fallbackSaturation}%`,\n\t} as CSSProperties;\n\n\treturn (\n\t\t<div\n\t\t\tclassName={cn(\"frosted-glass\", border && \"frosted-glass-border\", containerClass)}\n\t\t\tstyle={containerStyle}\n\t\t>\n\t\t\t{filterId ? (\n\t\t\t\t<>\n\t\t\t\t\t<div className=\"frosted-glass-filter\" style={{ filter: `url(#${filterId})` }} />\n\n\t\t\t\t\t<svg className=\"frosted-glass-defs\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\">\n\t\t\t\t\t\t<defs>\n\t\t\t\t\t\t\t<filter\n\t\t\t\t\t\t\t\tid={filterId}\n\t\t\t\t\t\t\t\tx=\"-50%\"\n\t\t\t\t\t\t\t\ty=\"-50%\"\n\t\t\t\t\t\t\t\twidth=\"200%\"\n\t\t\t\t\t\t\t\theight=\"200%\"\n\t\t\t\t\t\t\t\tfilterUnits=\"objectBoundingBox\"\n\t\t\t\t\t\t\t\tprimitiveUnits=\"userSpaceOnUse\"\n\t\t\t\t\t\t\t\tcolorInterpolationFilters=\"linearRGB\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<feTurbulence\n\t\t\t\t\t\t\t\t\ttype=\"fractalNoise\"\n\t\t\t\t\t\t\t\t\tbaseFrequency={`${baseFrequency} ${baseFrequency}`}\n\t\t\t\t\t\t\t\t\tnumOctaves={numOctaves}\n\t\t\t\t\t\t\t\t\tseed={seed}\n\t\t\t\t\t\t\t\t\tstitchTiles=\"stitch\"\n\t\t\t\t\t\t\t\t\tresult=\"noise\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<feGaussianBlur in=\"noise\" stdDeviation={noiseBlur} result=\"blurred\" />\n\t\t\t\t\t\t\t\t<feDisplacementMap\n\t\t\t\t\t\t\t\t\tin=\"SourceGraphic\"\n\t\t\t\t\t\t\t\t\tin2=\"blurred\"\n\t\t\t\t\t\t\t\t\tscale={scale}\n\t\t\t\t\t\t\t\t\txChannelSelector=\"R\"\n\t\t\t\t\t\t\t\t\tyChannelSelector=\"G\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</filter>\n\t\t\t\t\t\t</defs>\n\t\t\t\t\t</svg>\n\t\t\t\t</>\n\t\t\t) : null}\n\n\t\t\t<div className=\"frosted-glass-overlay\" />\n\t\t\t<div className=\"frosted-glass-specular\" />\n\n\t\t\t<div className={cn(\"frosted-glass-content\", className)}>{children}</div>\n\t\t</div>\n\t);\n}\n","type":"registry:ui","target":"@ui/fancy/components/frosted-glass/FrostedGlass.tsx"},{"path":"react/src/components/frosted-glass/frosted-glass.css","content":"/* Anchored on the root class: the Svelte compiler scoped these rules, plain CSS\n   would leak them into every consumer element sharing the class name. The rule\n   ORDER below is the source order - the fallback block's overlay override is\n   deliberately left where the source puts it (see the note on it). */\n.frosted-glass {\n\tposition: relative;\n\tdisplay: flex;\n\tbackground: transparent;\n\toverflow: hidden;\n\tcontain: layout paint;\n\tbox-shadow:\n\t\t0 2px 4px rgba(0, 0, 0, 0.1),\n\t\t0 0 8px rgba(0, 0, 0, 0.05);\n}\n\n.frosted-glass.frosted-glass-border::before {\n\tcontent: \"\";\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 4;\n\tborder-radius: inherit;\n\tpadding: 1px;\n\tbackground:\n\t\tconic-gradient(\n\t\t\tfrom -75deg at 50% 50%,\n\t\t\trgba(20, 60, 120, 0.5),\n\t\t\trgba(150, 200, 255, 0.1) 5% 40%,\n\t\t\trgba(20, 60, 120, 0.5) 50%,\n\t\t\trgba(150, 200, 255, 0.1) 60% 95%,\n\t\t\trgba(20, 60, 120, 0.5)\n\t\t),\n\t\tlinear-gradient(180deg, rgba(220, 240, 255, 0.5), rgba(240, 250, 255, 0.5));\n\tbox-shadow: inset 0 0 0 0.5px rgba(220, 240, 255, 0.5);\n\tpointer-events: none;\n\tmask:\n\t\tlinear-gradient(#fff 0 0) content-box,\n\t\tlinear-gradient(#fff 0 0);\n\tmask-composite: exclude;\n}\n\n/* backdrop-filter: blur(0) pulls the backdrop into this layer so the SVG\n   displacement filter can distort it */\n.frosted-glass .frosted-glass-filter {\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 0;\n\tbackdrop-filter: blur(0);\n\tisolation: isolate;\n\ttransform: translateZ(0);\n\twill-change: filter;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n\t.frosted-glass-filter {\n\t\tanimation: frosted-glass-settle 0.22s ease-out;\n\t}\n}\n\n@keyframes frosted-glass-settle {\n\t0% {\n\t\topacity: 0;\n\t}\n}\n\n/* Safari can't combine filter:url() with backdrop-filter, so it needs a plain-blur\n   fallback. -webkit-named-image is a WebKit-only feature query (Chromium and Firefox\n   return false). Ship the -webkit- prefixed backdrop-filter too for Safari and iOS 17 and older. */\n@supports (background: -webkit-named-image(i)) {\n\t.frosted-glass .frosted-glass-filter {\n\t\tfilter: none !important;\n\t\t-webkit-backdrop-filter: blur(var(--fg-fallback-blur)) saturate(var(--fg-fallback-saturation));\n\t\tbackdrop-filter: blur(var(--fg-fallback-blur)) saturate(var(--fg-fallback-saturation));\n\t}\n\n\t/* Same specificity as the unconditional `.frosted-glass-overlay` rule further\n\t   down, which therefore wins on source order and leaves this one inert. Kept\n\t   verbatim, in place: the Svelte source has the same dead override and the port\n\t   copies behaviour, bugs included. */\n\t.frosted-glass .frosted-glass-overlay {\n\t\tbackground: hsla(0, 0%, 100%, 0.5);\n\t}\n}\n\n.frosted-glass .frosted-glass-defs {\n\tposition: absolute;\n\twidth: 0;\n\theight: 0;\n}\n\n.frosted-glass .frosted-glass-overlay {\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 1;\n\tbackground: var(--fg-tint);\n}\n\n.frosted-glass .frosted-glass-specular {\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 2;\n\tborder-radius: inherit;\n\toverflow: hidden;\n\tbox-shadow:\n\t\tinset 1px 1px 0 var(--fg-highlight),\n\t\tinset 0 0 5px var(--fg-highlight);\n}\n\n.frosted-glass .frosted-glass-content {\n\tposition: relative;\n\tz-index: 3;\n\tdisplay: flex;\n\talign-items: center;\n\twidth: 100%;\n}\n","type":"registry:ui","target":"@ui/fancy/components/frosted-glass/frosted-glass.css"},{"path":"react/src/components/frosted-glass/index.ts","content":"\"use client\";\n\nexport { FrostedGlass } from \"./FrostedGlass\";\nexport type { FrostedGlassProps } from \"./FrostedGlass\";\n","type":"registry:ui","target":"@ui/fancy/components/frosted-glass/index.ts"}],"meta":{"license":"MIT","package":"fancy-ui-react","version":"0.7.0","source":"https://fancy-ui.rama.app/docs/components/frosted-glass?framework=react"}}