Communitygithub.com

kubai-liquid-glass

Add a liquid glass material to cards and panels over images, wallpapers, or video: background blur and brightness, edge refraction and color dispersion, automatically adjusting tint and text color for readability in light and dark mode while keeping the layout unchanged (liquid glass, glassmorphism).

What is kubai-liquid-glass?

This skill transforms UI surfaces (cards, players, toolbars, menus, popovers, toasts) that sit over images, wallpapers, or busy backgrounds into a dynamic 'liquid glass' material. It builds the effect as CSS tokens per state (light/dark, default/over dark) using a combination of tint, backdrop-filter with blur and saturation/brightness adjustments, and a multi-layered box-shadow for the rim. A custom SVG displacement map creates a lens-like refraction at the edges, with color splitting (red shifted 15% out, blue shifted 15% in) for a chromatic dispersion effect that only applies in Chromium browsers via url() in backdrop-filter. The material adapts to its background by sampling a 5×3 grid, adjusting tint density, saturation, and text color (light or dark ink) based on luminance and texture, while maintaining accessibility (contrast checks, reduced-transparency fallback, focus rings unchanged). It is designed for developer tools like Claude Code, Cursor, or Codex to apply automatically to an existing project without altering layout, fonts, or copy. Key features include a rim lens built from a displacement map scaled to surface size, per-surface adaptation without rebuilding maps on resize, and user-adjustable tint sliders for light and dark mode. Platforms: any web app using CSS and SVG filters. Limitations: Firefox skips the lens due to lack of url() support in backdrop-filter; surfaces under 32px or with their own compositing layer skip the lens to avoid rendering issues.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/kubai087/vibedesign-skills/tree/HEAD/skills/kubai-liquid-glass

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Liquid Glass

999 Tips to Make Your Vibe Product More Premium Issue #010 · @kubai087

Apply the following changes to the user's project. Write as if the user is speaking: I, me, my refer to the user; where it says to ask first, stop and ask the user before continuing.

Requirements

Give the cards and panels in my product a liquid glass material: clear glass that takes its color from the scene behind it, reads as a thick slab at the rim, adapts to what is behind it, and keeps its text readable in light and dark mode. Work inside my existing design system. This is a change of surface, not of layout: keep my markup, spacing, radii, fonts, icons and copy.

  1. Start from what exists
  • Find every surface that sits over an image, a wallpaper, video or a busy background: cards, players, search bars, toolbars, menus, popovers, toasts. List them with their component and where they are.
  • Find how the product switches between light and dark mode, and where its color tokens live. The glass goes into those tokens, not into each component.
  • Leave surfaces over a plain background alone; glass over a flat color only looks gray.
  1. The material as tokens Build it as one set of variables per state, so a surface opts in by using them. The numbers are a starting point, for a UI at its normal size.
  • Light glass, dark text (the default): tint white at 6–22% (by density, step 4); backdrop-filter blur(2px) saturate(180%) brightness(1.06), so the color comes from behind and stays vivid instead of milky. Edge: inset 1.5px 1.5px 1px -1px white 95%, inset -1.5px -1.5px 1px -1px white 55%, inset 0 0 0 0.5px white 30%, 0 0 0 0.5px black 6%, 0 6px 24px black 8%. Inner light, on a layer inside the surface: a radial highlight from the top left (white 30% fading out by 55%), and soft inset glows just inside the rim, brighter at the top and left, a little shade at the bottom.
  • Light mode over a dark area, light text: tint rgb(16 18 22) at 10–30%; filter blur(2px) saturate(170%), then brightness(0.85); edge: a faint inset white line on top and a 0.5px dark outline.
  • Dark mode: tint rgb(20 20 24) at 16–38%; filter blur(2px) saturate(160%) brightness(0.8), which dims like a multiply with black instead of going muddy; the same edge and inner light at about a third of their strength, with a darker outline and shadow.
  • Ink, one color in fixed steps, used for everything drawn on the glass: on light glass black 86% (titles, icons, times, progress), rgb(60 60 67) at 70% (secondary); mix-blend-mode multiply; on dark glass white 94%, rgb(235 235 245) at 64%; mix-blend-mode plus-lighter. Draw icons in the opaque color and fade the whole icon with opacity: a translucent color darkens where a shape's strokes and fills overlap.
  • A highlighted row on light glass is a lighter layer of the glass: white 42% on hover, 76% when selected, with a white stroke. Never a gray wash.
  • Register the numeric and color tokens with @property so a surface glides between states instead of jumping.
  1. Apply it in four declarations Each surface changes only these, and its markup stays as it is:
  • background: the tint.
  • backdrop-filter: the material's filter, then the rim lens (step 3) last, so the color steps fold into one pass and the bend stays crisp.
  • box-shadow: the edge.
  • color: the ink, with the blend mode on everything drawn inside. Hover brightens the tint by about 14% instead of lifting a shadow.
  1. The rim lens
  • Build a displacement map for each surface: red is the sideways bend, green the vertical one, 128 is none. Only a rim bends; the middle stays flat.
  • The rim is about 44px wide on a card (min(44px, the short side / 3.5), never under 4px). For a thick slab, a point d from the edge looks inward by 1.1 × rim × (1 - d / rim)^2.6: hard at the edge, where the scene folds back on itself, easing to nothing at the rim's inner edge.
  • Draw the map for the same corner the CSS draws. If the surface uses corner-shape: superellipse(), follow that curve, not a circle, or the bend and the rim light miss each other at the corners.
  • Put it in an SVG filter with feImage (the map) and feDisplacementMap (scale = 2 × the largest offset), and add url(#id) at the end of backdrop-filter.
  • Split it into colors: three passes, red 15% further and blue 15% less, each kept to its channel with feColorMatrix and added back with screen blends. Check the corners of wide rims over busy backgrounds; lower the split where it turns into a haze.
  • Only Chromium draws url() in backdrop-filter. Check CSS.supports('backdrop-filter', 'url(#a)') and skip Firefox, which parses it and draws nothing. Everywhere else the CSS-only glass stays.
  • Wait for the map image to decode before pointing a surface at the filter, or it draws without its blur. Give every filter a unique id and its own . Build maps once per radius and rim width and reuse them; on resize, move the map, don't rebuild it.
  • Skip the lens on surfaces under 32px, and on surfaces with will-change or their own compositing layer (menus, animated panels), where Chrome can draw the map instead of the bent backdrop.
  1. Adapt to what is behind
  • For each surface, sample the background under it at a 5 × 3 grid, drop the two darkest and two brightest points, and average. Luminance is (0.299 R + 0.587 G + 0.114 B) / 255; texture is the brightest point minus the darkest.
  • Ink: in light mode, light text when the luminance is under 0.5. Keep the current ink within ±0.05 of the line so a surface never flickers at it. Dark mode is always light text. Neighbouring surfaces in one row share one decision.
  • Density (0 thin, 1 dense) = 0.55 × how close the background is to the ink's own brightness + 0.7 × texture + 0.3 × chroma. It moves the tint between its thin and dense alpha.
  • Saturation kept = 1 - 0.75 × chroma, at least 0.45, so a vivid background doesn't stain the glass.
  • Sample again when the background, the theme or a surface's position changes, and remember the last ink so the next load opens in it.
  • If the background is not an image you can read (live video, cross-origin content), pick the ink from the theme and use the dense tint.
  1. Let people set the tint
  • Add one setting for light mode and one for dark that scale the tint, from 0 to 1.5 (1 is the material as designed). Below 1 the brightness lift in the filter thins with it, so at 0 only the blur, the rim and the shadow are left.
  • Each theme keeps its own value; switching themes glides to that theme's value.
  1. Keep it accessible
  • Check text contrast on the busiest and the darkest background the product allows, at the default tint; raise density, not the ink's opacity, until it passes.
  • Respect prefers-reduced-transparency and forced colors: fall back to a solid surface in the same tint at full opacity.
  • Keep focus rings, disabled states and error colors as they are; failures keep their red.
  1. Deliver
  • First list the surfaces you will change, which get the lens and the color split, and which you leave solid and why.
  • Then add the tokens, the lens helper and the two settings, switch the surfaces over, and list every file you touched.
  • Don't change layout, fonts, radii or copy. If a surface would need a new component to work as glass, stop and ask me first.

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

kubai-book-cards

卡片在悬停或聚焦时像书一样翻开一定角度,显示里面的内页,静止时外观保持不变。提供普通卡片、拟物精装书和极简文档三种风格。适用于文档、知识库、作品集和模板市场(book hover cards)。

kubai-easing-curves

按使用场景为项目中的动画设置缓动曲线和时长:入场用 ease-out,离场用 ease-in,位置变化用 ease-in-out,小的确认反馈用 overshoot,拖动松手后用 spring,并统一为动效 token(easing, motion curves)。

kubai-holo-card

把产品里代表身份或收藏的卡片(会员卡、门票、徽章、个人卡片)改成镭射卡片:卡片朝指针方向 3D 倾斜,镭射与高光随光线移动,内部图案按深度产生视差,静止时轻微晃动,点击可翻到背面并显示厚度。附 Prism、Rainbow、Pearl、Sparkle、Chrome、Etched 六种材质的推荐参数,以及手感、厚度、翻转和层次的几档预设。开始前逐项询问,每项给出推荐值,由你选择或调整,确认后再按现有技术栈改造(holographic card, foil, 3D tilt, parallax)。

kubai-scroll-cards

改造现有长页面:选出值得讲的段落,用五种由滚动驱动的卡片交互呈现——层叠卡片(新卡片逐张盖住旧卡片,旧卡片缩小、变暗)、卡组飞出(顶部卡片向一侧甩出,下一张顶上来)、横向展廊(页面固定,纵向滚动推动横向作品集)、封面轮播(中间一张最大,两侧缩小、转开、变暗)、图片展开(小图铺满屏幕,标题从景物后升起形成景深)。效果全部由滚动位置驱动,读者控制节奏,回滚即倒放,不劫持滚动;尺寸按不同屏幕和视窗高度计算,手机工具栏不会挡住内容,矮屏自动退回普通段落。附多档预设,开始前逐项询问,由你选择或调整,确认后按现有技术栈实现(scroll-driven animation, sticky, cover flow, svh)。

Related Skills