explaingit

jeantimex/liquid-glass-html-in-canvas

12TypeScriptAudience · developerComplexity · 3/5Setup · moderate

TLDR

A TypeScript library that adds Apple-style frosted glass effects (blur, light refraction, chromatic aberration, edge highlights) to HTML elements inside a browser canvas using WebGPU and experimental Chrome APIs.

Mindmap

mindmap
  root((liquid-glass-html-in-canvas))
    What it does
      Frosted glass on HTML elements
      Background blur and refraction
      Chromatic aberration
      Edge highlights and shadows
    Tech
      TypeScript
      WebGPU
      Experimental canvas API
      CSS custom properties
    Setup
      npm install
      Chrome with flag enabled
      Per-frame render call
    Audience
      Frontend developers
      UI designers
      Vibe coders
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add Apple-style frosted glass panels to HTML elements in a browser canvas with configurable blur, refraction, and corner radius.

USE CASE 2

Build high-performance visual glass effects using WebGPU directly in the browser without server-side rendering.

USE CASE 3

Customize each glass panel individually using CSS variables for blur strength, light refraction, chromatic aberration, and corner rounding.

USE CASE 4

Create frosted glass modals, cards, or overlays in a TypeScript UI by initializing LiquidGlassCanvas and calling render() each animation frame.

Tech stack

TypeScriptWebGPUCanvas APICSS

Getting it running

Difficulty · moderate Time to first run · 30min

Requires Chrome with the experimental html-in-canvas flag enabled, WebGPU works by default in Chrome 113+ and Edge 113+.

In plain English

This TypeScript library applies a frosted glass visual effect, similar to the translucent panels in Apple's design language, to HTML elements rendered inside a browser canvas. The effect includes background blur, light refraction, chromatic aberration (a subtle color fringing that mimics real glass), edge highlights, and drop shadows, all configurable through standard CSS variables. The approach relies on two experimental browser features that are not yet in standard web specifications. The first is an experimental canvas API that lets HTML elements live inside a canvas element and be drawn using a special drawing command. The second is WebGPU, a newer graphics API that gives web pages direct access to the graphics card for high-performance rendering. As of this repository, the html-in-canvas feature requires Chrome with an experimental flag turned on, WebGPU works by default in Chrome 113 or later and Edge 113 or later, and is behind a flag in Firefox Nightly. To add the effect to a page element, you place HTML inside a canvas with a special attribute, add the class liquid-glass to any element you want to look like frosted glass, and call a render method on each animation frame. Each glass element can be individually tuned using CSS custom properties: for example, --lg-blur controls how much the background blurs through the panel, --lg-refraction controls how much the glass bends the light, and --lg-corner-radius sets the roundness of the corners. The library exports a single class, LiquidGlassCanvas, which handles WebGPU setup and provides a render() method for use in the canvas paint callback. A destroy() method cleans up GPU resources when the component is no longer needed. Installation is via npm: run npm install and npm run dev to start the development server. The README includes a full working HTML example and a reference table for all available CSS properties with their default values and descriptions.

Copy-paste prompts

Prompt 1
Using liquid-glass-html-in-canvas, add a frosted glass card to a portfolio website. Show me the HTML structure, how to apply the liquid-glass class, and CSS variable values to set blur to 20px and corner radius to 16px.
Prompt 2
I want to add a glass-effect modal dialog using LiquidGlassCanvas in TypeScript. Show me how to initialize the class, hook render() into the animation loop, and call destroy() when the modal closes.
Prompt 3
Help me tune the chromatic aberration and refraction in liquid-glass-html-in-canvas for a realistic subtle look. Explain what --lg-refraction and --lg-chromatic-aberration control and suggest good starting values.
Open on GitHub → Explain another repo

← jeantimex on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.