Skip to content

Getting Started

This project draws inspiration and ideas from Chris Feijoo's article Liquid Glass in the Browser: Refraction with CSS and SVG.

Browser compatibility: The Liquid Glass effect relies on SVG filters as backdrop-filter, which is currently only supported in Chromium-based browsers (Chrome, Edge, Opera, etc.). For unsupported browsers, a glassmorphism blur fallback is applied automatically.

Installation

Install the package via your preferred package manager:

bash
pnpm add liqvued
bash
npm install liqvued
bash
yarn add liqvued

Global Registration

Register the plugin globally in your app entry point:

ts
import { createApp } from 'vue'
import LiqvuedPlugin from 'liqvued'
import App from './App.vue'

const app = createApp(App)
app.use(LiqvuedPlugin)
app.mount('#app')

Now the <Liqvued> component is available anywhere in your templates.

Local Import

You can also import the component locally in individual SFCs:

vue
<script setup lang="ts">
import { Liqvued } from 'liqvued'
</script>

<template>
  <Liqvued :radius="32" :bezel="22" :thickness="42" :refraction="1" :blur="0.4" surface="convex">
    <p>Your content here</p>
  </Liqvued>
</template>

Basic Usage

Wrap any content in <Liqvued> and place it over a background to see the refraction effect:

vue
<script setup lang="ts">
import { Liqvued } from 'liqvued'
</script>

<template>
  <div
    style="background: url('https://picsum.photos/seed/liqvued/1200/600') center/cover;"
  >
    <Liqvued
      :bezel="45"
      :thickness="60"
      :refraction="3"
      :glare-angle="285"
      :specular-opacity="0.2"
      glass-background="#00f0f055"
      :blur="0.8"
      surface="convex"
    >
      <h2>Hello from behind the glass</h2>
    </Liqvued>
  </div>
</template>

The glass effect is driven by two key primitives:

  • SVG <feDisplacementMap> — refracts the background based on the surface profile
  • CSS backdrop-filter: blur() — adds frosted glass blur

A per-pixel displacement map is generated on a Canvas, encoded as a PNG data URL, and injected into the SVG filter via <feImage>.

Surface Types

TypeDescriptionAppearance
convexSquircle convex profileSoft, pill-like edges with inward refraction
concaveInverted convex profileInward-curving dish-like refraction
lipSmooth convex-to-concave transitionS-curve that lifts at center and dips at edges

Props

PropTypeDefaultDescription
asstring | Component'div'HTML tag or Vue component to render as
asPropsobject{}Props passed to the rendered element/component
radiusnumber32Corner radius in pixels
bezelnumber22Width of the displacement bezel in pixels
thicknessnumber42Maximum displacement magnitude in pixels
refractionnumber1Refraction index multiplier
blurnumber0.4CSS backdrop-filter blur amount
surfaceSurface'convex'Surface profile shape
specularOpacitynumber0.45Opacity of the specular highlight
glareAnglenumber-60Light source angle in degrees for specular highlight
glassBackgroundstringGlass panel background color (auto-derived from asProps.color when available)

MIT Licensed