360 Secure SkillHub
360 安全技能中心

liquid-glass

提供跨平台复现 Liquid Glass 的完整方案:涵盖背景模糊、边缘透镜位移、动态高光、色散和动效规则,并针对 Web、Flutter、Android、Tauri、GPU 着色器等给出实现指引、设计令牌与验收清单。

分类:开发
darkiifr
热度 0.66
最近更新 2026-11-15 11:47:31

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add darkiifr/liquid-glass-skill-everyos/liquid-glass
兼容性
通用兼容
联网要求
不联网
数据出网
数据不出本机
Metadata
name
liquid-glass
description
Reproduce Apple's Liquid Glass material (iOS 26 / macOS Tahoe / visionOS, WWDC 2025) faithfully in any language, without Swift. Covers web (CSS+SVG), Flutter, Android/Kotlin (AGSL), Tauri (Rust, window-vibrancy), Unity/HLSL, Godot, Qt/QML, and any GPU-shader stack. Includes full optical math (superellipse corners, lens displacement, Fresnel rim lighting, chromatic dispersion, metaball blending) and real external packages per platform. Use whenever the user asks for "Liquid Glass", "verre liquide", refractive glass UI, or wants a glass effect "more liquid"/"not glassmorphism" with edge refraction, lensing, specular highlights, or dispersion — even without naming Apple or a framework. NOT for requests that explicitly want plain flat frosted-glass/glassmorphism.

Liquid Glass (cross-platform, no Swift)

Why this skill exists

Liquid Glass (introduced WWDC 2025, shipped iOS 26 / macOS Tahoe / visionOS) is not glassmorphism. Glassmorphism is a translucent card with a background blur — a static, decorative trick. Liquid Glass is a simulated optical material: it bends the content behind it like a real lens, adds a specular highlight that reacts to light/motion, subtly disperses color at high-distortion edges, and behaves like a compressible gel under touch. Reproducing it convincingly on a non-Apple stack means reproducing the optical behavior, not copying the blur-and-opacity CSS that most tutorials call "liquid glass."

Read this file fully before writing any code. Then jump to the one references/ file that matches the target stack — don't read all of them.

Non-negotiable: never ship glassmorphism and call it done

This is the one rule in this skill that has no exceptions. Blur + translucency + a border is the default every framework/tutorial reaches for, it's one line of CSS, and it is not Liquid Glass — it's the thing this skill exists to replace. Before treating any implementation as finished, run this check:

Cover the light source and see if anything changes. If you move the pointer (or tilt, or scroll) and nothing about the surface reacts — no highlight moving, no edge bending — you've built glassmorphism, whatever the CSS class or component is named. Ship a #1-only (blur/saturation, ingredient list below) implementation only if the user has explicitly asked for plain frosted glass, not Liquid Glass — never as a shortcut, a "good enough for now," or because the target platform makes ingredient #2 harder. If a platform genuinely can't do edge displacement (see the per-platform fallback notes in web.md/tauri.md), say so explicitly to the user and name the gap — don't silently deliver blur and let them assume they got the real thing.

The five ingredients below are ordered by how much they matter to the illusion, not by implementation convenience — #2 (the lens) is what actually separates this from glassmorphism, not #1 (the blur), even though #1 is the one every tutorial stops at.

The physical model (implement this, on any platform)

Every faithful implementation needs these five ingredients. A renderer that only does #1 is glassmorphism; Liquid Glass needs at least #1–#3.

  1. Backdrop capture + blur/saturation boost. Sample or blur whatever is behind the element (backdrop-filter, a render-texture pass, a framebuffer blit — platform-dependent). Push saturation up (~150–200%) so colors underneath stay vivid instead of graying out under blur.
  2. Edge-concentrated lens displacement. This is the part glassmorphism skips entirely, and the part that actually sells the illusion. Do not distort uniformly across the surface — Apple's own engineers describe it as: shrink the interface slightly, then stretch the edges outward, with the center staying nearly undistorted. Implement as a 2D displacement field:
    • For a pixel at normalized position (nx, ny) in [-1, 1] relative to the element's center, radial distance d = min(1, sqrt(nx² + ny²)).
    • falloff = d ^ k where k ≈ 2 – 2.5 (concentrates displacement at the edge, leaves the center ~neutral).
    • Displacement vector: (dx, dy) = (nx * falloff, ny * falloff) * strength, where strength is tuned per component (small for a whole navbar, larger for a small round button — see references/design-tokens.md).
    • Sample the blurred backdrop at (pixel + (dx, dy)) instead of pixel. This single step is what turns blur into a lens.
  3. Specular highlight that reacts to input. A soft radial/linear highlight biased toward one corner (simulating a light source), whose position shifts with pointer position, device tilt, or scroll — never fully static. This is what makes the surface read as "wet"/gel rather than painted-on glass.
  4. Adaptive contrast, not fixed opacity. The tint/opacity of the glass should respond to what's behind it (darker backdrop → element brightens itself slightly, and vice versa) so text stays legible. If the platform can't do this cheaply, a light/dark mode toggle plus a safe fixed opacity is an acceptable simplification — but never let contrast drop below ~4.5:1 for text.
  5. Chromatic dispersion at displaced edges (optional, subtle). Sample the red and blue channels of the backdrop with a 1–2px extra offset in opposite directions, only where displacement is large (i.e., near the edge). This is the "rainbow sliver" effect from the WWDC keynote. Keep it barely visible — Apple uses it very sparingly, and overdoing it looks cheap.

Also implement, as motion/interaction rules (not optics, but essential to the illusion). For complete spring presets, sequencing, shared-element morphs, scroll behavior, and component recipes, read references/motion-and-transitions.md. For Motion and GSAP integration, read references/motion-gsap.md. For typography, continuous corners, and radius rules, read references/typography-radius-and-shape.md:

  • Gel compression: on press, the element scales down slightly (~4–6%) and its highlight brightens, as if the material compressed rather than just "a button got smaller."
  • Metaball merging: when two Liquid Glass elements touch or overlap (e.g., a tab bar item expanding into a search field), they should visually blend at the seam rather than simply overlap. Full metaball simulation is expensive; a cheap approximation is cross-fading a shared blurred mask at the seam. Skip this for isolated components — only implement it if the user's brief specifically involves merging/morphing elements.
  • Respect reduced-motion and reduced-transparency: when the platform exposes these (CSS prefers-reduced-motion/prefers-reduced-transparency, Android's equivalent accessibility flags, etc.), fall back to a static tinted surface with no highlight animation and no displacement motion.

Choosing where to implement it

Target Technique Read
Web (HTML/CSS/JS, React, any framework) backdrop-filter + inline SVG feImage/feDisplacementMap, generated per-element at runtime references/web.md, references/motion-and-transitions.md, references/motion-gsap.md, references/typography-radius-and-shape.md
Anything with a GPU shader stage (Unity, Godot, WebGPU, OpenGL/WebGL, raw C/C++, game engines in general) A single portable fragment shader implementing the displacement formula above references/shaders.md, assets/liquid-glass.frag
Flutter / Dart (iOS, Android, desktop, web — one codebase, zero Swift) BackdropFilter + dart:ui FragmentProgram (AGSL-like GLSL) references/flutter.md
Android native (Kotlin/Jetpack Compose) RenderEffect + RuntimeShader (AGSL) — Android has never used Swift, this is the natural fit references/android.md
Desktop apps (Qt/QML, C++, or similar retained-mode UI toolkits) ShaderEffect/custom QSGMaterial running the same fragment shader references/desktop.md
Tauri (Rust + system webview: WebView2/WKWebView/WebKitGTK) Native OS blur via the window-vibrancy crate + the web recipe above, or a WebGL canvas running the same shader for full cross-OS refraction (the SVG-filter method only works on the Windows/WebView2 leg) references/tauri.md

All of these implement the same physical model above — only the shader language and the way you get "what's behind this pixel" into the shader changes. Read references/algorithm.md first (now with the full derivation: superellipse corner math, the displacement falloff derivation, Fresnel-Schlick rim lighting, wavelength-based dispersion, and metaball smooth-min blending) before jumping to a platform file — every platform file assumes you've read it and just transcribes its formulas into a specific API.

Don't want to hand-roll every layer? references/packages.md lists real, verified-to-exist external packages per platform (React, React Native, Flutter, Rust) and when reaching for one beats implementing this skill's math yourself.

Design tokens

Numeric values (blur radii, continuous-corner radii, typography, tint colors, spring presets, timing curves, contrast minimums, and now the optical constants — superellipse exponent, Fresnel terms, dispersion wavelengths, metaball blend radius) drawn from Apple's HIG and observed OS behavior are in references/design-tokens.md. Use these as defaults; don't invent your own blur/saturation numbers from scratch.

Quality checklist before calling it done

  • Typography uses the system San Francisco stack on Apple platforms, appropriate optical sizing, and sufficient weight over blur.
  • Radius follows a component scale; masks, clipping, focus rings, and shadows share the same continuous-corner geometry.
  • Motion or GSAP owns each animated property; no competing transform writers.
  • Center of large surfaces (nav bars, sidebars) stays visually calm; distortion is visible mainly at edges/corners.
  • Highlight moves with viscous lag — pointer, touch, scroll, or a slow idle drift — never a single frozen gradient or raw flashlight tracking.
  • Press/release couples scale, shadow, highlight, blur density, and refraction; it is not a transform-only button animation.
  • Morphing controls use one continuous glass surface and preserve highlight direction through the transition.
  • Contrast checked against a bright AND a dark backdrop, not just one demo background.
  • Reduced-transparency / reduced-motion fallback exists and was tested.
  • No more than one primary Liquid Glass layer stacked per view (Apple explicitly advises against layering multiple glass surfaces — it confuses hierarchy and tanks performance).
  • Performance: displacement/shader cost is paid once per element size (cache the displacement map / compiled shader), not recomputed every frame unless the element is actively resizing.
  • Corners use the superellipse formula from references/algorithm.md §1 for anything larger than a small chip/icon button — a plain circular border-radius reads as noticeably "not quite right" once you've seen the two side by side.
  • If targeting more than one OS through a single webview/runtime (Tauri, Electron-adjacent, or a cross-platform mobile toolkit), tested on each target's actual rendering engine — not just the one on your dev machine. See references/tauri.md for the concrete WebView2/WKWebView/WebKitGTK gap; the same category of gap exists on other cross-platform stacks.

Publishing this skill to skills.sh

This folder already follows the Agent Skills format skills.sh indexes. To publish:

git init
git add .
git commit -m "Add liquid-glass skill"
gh repo create <your-org>/liquid-glass-skill --public --source=. --push
# or: git remote add origin <your-repo-url> && git push -u origin main

Once the repo is public and contains this SKILL.md (at the repo root or under skills/liquid-glass/), it's installable immediately via npx skills add <org>/<repo> and becomes discoverable on skills.sh through install telemetry — no separate manual submission step is required.