liquid-glass
Liquid glass — Apple-style frosted, refracting surfaces. Use when the user asks for glassmorphism, frosted/translucent panels, cards, menus or a glass topbar; when a glass surface looks wrong (gray, flat, invisible, unreadable text); or when another skill needs the glass recipe.
- License 许可
- MIT
- 最近更新
- 2026-11-07
- Stars
- ★ 11
- Forks
- 5
01 前言 Front Matter
- name
- liquid-glass
- description
- Liquid glass — Apple-style frosted, refracting surfaces. Use when the user asks for glassmorphism, frosted/translucent panels, cards, menus or a glass topbar; when a glass surface looks wrong (gray, flat, invisible, unreadable text); or when another skill needs the glass recipe.
02 资源文件 4
- 资产文件assets/liquid-glass.css12.6 KB
- 脚本assets/liquid-glass.directive.ts14.8 KB
- 参考文档references/recipes.md4.5 KB
- 参考文档references/refraction.md6.7 KB
03 SKILL.md 正文
Liquid Glass
Glass is two layers, and the CSS one is not the interesting one.
- CSS paints the tint and the rim — a near-transparent white→gray gradient plus three inset highlights that read as a polished edge. This is what most "glassmorphism" snippets stop at.
- Refraction bends the backdrop through the panel's edge, the way real glass does: a displacement map baked per element and consumed as
backdrop-filter: url(#filter). This is what makes it liquid rather than a blurred rectangle.
They ship as a pair — a class and a directive on the same element:
<div class="liquid-glass" appLiquidGlass>…</div>
assets/liquid-glass.css is the CSS layer, self-contained (its own tokens, light and dark).
assets/liquid-glass.directive.ts is the refraction layer for Angular. Any other framework: port it, see references/refraction.md — the port is transcription, not design.
The four rules
Each of these has one failure mode, and in every case the browser shows you something plausible instead of an error.
1. Glass needs a backdrop. Build it first.
Glass shows what is behind it. Behind a flat background there is nothing to show, so the panel renders as a faintly outlined gray box and the effect reads as broken — which sends people reaching for more blur and more opacity, the exact move that kills it.
So the ambient mesh is part of the recipe, not decoration: off-screen radial glows in a few hues (violet / pink / cyan), fixed to the viewport behind the content. Colour that the glass can pick up.
<body class="liquid-glass-backdrop">
Verify this before styling a single panel: the page must look subtly uneven with no glass on it at all.
2. The glass is colorless — the colour arrives from behind.
The tint is white→70%-gray at 6% alpha in both themes. That is deliberate: hue in the tint fights the hue coming through the panel and the surface turns muddy. If a surface must be branded (a primary CTA, a FAB), override the tint locally and leave the rim, the border and the refraction alone:
.my-fab {
/* refraction still comes from the directive */
background: linear-gradient(155deg, rgba(79, 70, 229, 0.55), rgba(67, 56, 202, 0.42));
border: 1px solid rgba(79, 70, 229, 0.5);
}
3. A child of a glass panel paints no surface of its own.
No background, no border, no second radius — the panel already supplies all three. An opaque fill paints over the refracted backdrop, which is the whole effect; a nested border draws a hard edge across the rim. Panels inside a glass dock, rows inside a glass card, a header band inside a glass section: all transparent, separated by spacing and type weight instead.
The cost of getting this wrong is a surface that reads darker and deader than its neighbours, and nothing points at the cause.
4. Refraction is progressive enhancement, and you cannot feature-query it.
backdrop-filter referencing an SVG filter renders in Chromium only. Safari parses it and paints nothing — so @supports reports success and the panel goes blank. Gate on engine (navigator.userAgentData.brands, Chrome/ in the UA), and let everything else keep the stylesheet's plain backdrop-filter: blur(3px) saturate(125%) fallback. The directive already does this; keep it if you port.
Pick the tier
Refraction bakes a canvas displacement map per element size, so it is priced per surface. Match the tier to the element:
| Tier | What it is | Use for |
|---|---|---|
liquid-glass-chip |
tokens + blur(6px), no directive |
chips, pills, badges, anything small or repeated in bulk |
liquid-glass + directive |
the full effect | cards, panels, topbars, circular controls, FABs |
liquid-glass-menu |
blur(22px) + a 55% wash of the overlay surface, no directive |
dropdowns, popovers, context menus |
liquid-glass liquid-glass--modal + directive |
glass with an opaque frost layer over the tint | dialogs |
The menu and modal tiers exist for the same reason: text has to stay readable. A dropdown floats over arbitrary page content and a dialog over a scrim, so both trade some transparency for a wash — a menu through heavy blur, a modal through a theme-flipping frost (white in light, dark in dark). Do not "fix" either back to plain .liquid-glass.
Adding glass to a project
- Copy
assets/liquid-glass.cssin and link it. Confirm the app setsdata-theme="light|dark"on<html>before first paint — the CSS keys both themes off that attribute; the file header carries the boot snippet. - Put
liquid-glass-backdropon the page shell. Stop and look: uneven, colored, no panels yet. - Apply a tier per element. Radius stays on the element (the directive reads the computed
border-radiusto shape the map). - Non-Angular: port the directive per
references/refraction.md. - Walk the checklist below. Every line is a bug someone shipped.
Checklist
- [ ] The backdrop is visible with all glass removed.
- [ ] No child of a glass panel sets
backgroundorborder. - [ ] Both themes valued for every token you added, and both eyeballed — a rim tuned for dark disappears on white.
- [ ] Text on glass stays legible over the busiest part of the backdrop, not the calm part you happened to screenshot.
- [ ] Non-Chromium (or directive removed): still a decent frosted panel, nothing blank.
- [ ] Chips and repeated elements are on the CSS-only tier, not the directive.
- [ ] Nothing hardcodes a hex where a token exists.
More variants, hover, and the pitfalls behind each rule: references/recipes.md.
04 同仓库更多 Skills
xhs-pharma-social-listening
Run evidence-disciplined Xiaohongshu social listening for foreign pharma employee pain points. Use when the user asks to collect and analyze notes/comments about pharma companies, aliases, roles, compliance, medical affairs, or AI topics, then produce a cited and scored sampled-insight report. Includes independent-evidence counting, MediaCrawler batch collection, and CAPTCHA/461 fallback to Agent Reach/OpenCLI.
healthcare-phi-compliance
Protected Health Information (PHI) and Personally Identifiable Information (PII) compliance patterns for healthcare applications. Covers data classification, access control, audit trails, encryption, and common leak vectors. Use when code touches PHI or PII in a healthcare system, or when auditing access control, audit trails, or leak vectors.
healthcare-eval-harness
Patient safety evaluation harness for healthcare application deployments. Automated test suites for CDSS accuracy, PHI exposure, clinical workflow integrity, and integration compliance. Blocks deployments on safety failures. Use when a healthcare deployment must be gated on patient-safety tests for CDSS accuracy, PHI exposure, and workflow integrity.
healthcare-emr-patterns
EMR/EHR development patterns for healthcare applications. Clinical safety, encounter workflows, prescription generation, clinical decision support integration, and accessibility-first UI for medical data entry. Use when building EMR or EHR features such as encounter workflows, prescription generation, or clinical data entry UI.
healthcare-cdss-patterns
Clinical Decision Support System (CDSS) development patterns. Drug interaction checking, dose validation, clinical scoring (NEWS2, qSOFA), alert severity classification, and integration into EMR workflows. Use when building clinical decision support — drug interaction checks, dose validation, clinical scoring, or alert severity.
dxy-task-clarify
用户的请求含糊、缺背景、缺资料说明、缺读者或用途时使用。先用少量带选项的追问把任务问清楚,写成任务卡,用户确认后再执行。尤其适用于医生、科研人员和药企各岗位的工作,例如「帮我分析一下这些数据」「帮我准备明天的拜访」「写个总结」「做个 PPT」「回一下这封邮件」「整理一下会议纪要」「整理一下这些文献」「帮我准备下周的讲课」「写个病例汇报」「帮我写个提示词」。用户说「先问我」「帮我理清需求」「我不知道怎么描述」「我不会问 AI」时也使用。用途、资料、读者都已说清的请求,纯翻译,以及写代码、改代码,不使用。