For Tailwind CSS v3 docs, click here.

Liquid Glass Effect

A visually striking glassmorphism effect using SVG displacement filters similar to Apple Liquid Glass.

API

Prop NameTypeDefaultDescription
radiusnumber16Border radius for the glass container corners (in pixels).
bordernumber0.07Relative border thickness affecting displacement filter inner margin.
lightnessnumber50Lightness (0-100) of the overlay color in HSL scale.
blendstring"difference"CSS blend mode used between red and blue displacement layers for the distortion effect.
xChannel"R" | "G" | "B""R"Channel from displacement image to use for horizontal displacement.
yChannel"R" | "G" | "B""B"Channel from displacement image to use for vertical displacement.
alphanumber0.93Alpha transparency of the overlay color (0-1).
blurnumber11Gaussian blur radius applied to the overlay.
rOffsetnumber0Additional scale offset for red displacement map.
gOffsetnumber10Additional scale offset for green displacement map.
bOffsetnumber20Additional scale offset for blue displacement map.
scalenumber-180Base scale factor for displacement effects, combined with individual channel offsets.
frostnumber0.05Opacity factor controlling the frosted glass background overlay strength.
classstring""Additional CSS classes applied to the inner slot container wrapping content.
containerClassstring""Additional CSS classes applied to the outer container div.

Installation

Install using CLI

npm
pnpm
bun
yarn
npx shadcn-vue@latest add "https://registry.inspira-ui.com/liquid-glass.json"

Install Manually

Copy and paste the following code:

LiquidGlass.vue

Features

  • Customizable glass effect: Control blur, displacement, color channels, and blend modes for a unique glass morphism style.
  • Responsive SVG displacement filter: Dynamically adjusts to container size changes using ResizeObserver.
  • Multi-channel displacement: Applies independent displacement maps for red, green, and blue channels for rich distortion.
  • Backdrop-filter integration: Uses CSS backdrop-filter for real-time background blurring with filter fallback.
  • Scoped styling: Encapsulated styles prevent bleed and ensure smooth border-radius and shadows.
  • Flexible content wrapper: Slot container for any nested content with custom class support.

Credits

  • Inspired by Apple Liquid Glass.