Liquid glass for Vue 3 and Nuxt, rendered with WebGL2 shaders. It does real refraction, lens distortion, chromatic aberration, frost and edge lighting in Chrome, Edge, Firefox and Safari.
- Real shader. A signed distance field masks each lens, which has a quarter-circle bevel. It does not use an SVG displacement filter, so Safari and Firefox render the same effect as Chrome.
- Zero cost at idle. Frames render on demand and the page shares one WebGL context. An idle
page makes no
requestAnimationFrameor GL calls. - Accessible by default. It respects
prefers-reduced-motion,prefers-reduced-transparency,prefers-contrast,forced-colorsand Save-Data. - SSR-first. The server renders a CSS
backdrop-filterfallback and the client adds the WebGL canvas after mount. Hydration has no warnings and needs no<ClientOnly>. - Small. The main entry is under 12 KiB min+gzip. snapDOM, the optional DOM-capture library, loads only when a snapshot backdrop needs it.
pnpm add @mahbodhastam/liquid-glass
# optional, for glass over arbitrary HTML:
pnpm add @zumer/snapdomIt requires Vue 3.4 or newer. For Nuxt, it requires Nuxt 3.13 or newer, including Nuxt 4.
// main.ts
import { createLiquidGlass } from '@mahbodhastam/liquid-glass'
app.use(createLiquidGlass())<script setup lang="ts">
import { ref } from 'vue'
const hero = ref<HTMLImageElement | null>(null)
</script>
<template>
<section class="relative">
<img ref="hero" src="/hero.jpg" alt="" class="absolute inset-0 size-full object-cover">
<LiquidGlass :source="hero" class="rounded-3xl p-6" :blur="12" :refraction="0.4">
<h2>Content stays real DOM</h2>
</LiquidGlass>
</section>
</template>// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@mahbodhastam/liquid-glass/nuxt'],
})Components and composables are auto-imported.
The official docs cover backdrops, props, composables, accessibility, performance, quality tiers and browser support. Benchmark numbers and methods are in docs/perf.md.
pnpm install
pnpm build # tsdown builds dist: index, core, snapdom, nuxt
pnpm dev # Vite playground (build first; it imports dist)
pnpm dev:nuxt # Nuxt SSR fixture
pnpm test # unit (Vitest + happy-dom)
pnpm test:e2e # real WebGL: Chromium, Firefox, WebKit, Nuxt SSR
pnpm size # 12 KiB min+gzip budget
pnpm bench # presentation benchmarkMIT
