Avenra
Liquid GlassAPI Reference
Liquid GlassAPI Reference

createLiquidGlass

The core factory for applying glass effects.

createLiquidGlass

The core factory function that applies the physics-based glass effect to any existing DOM element.

Basic Usage

import { createLiquidGlass } from '@avenra/liquid-glass';

const glass = createLiquidGlass('#my-div', {
  glassThickness: 100,
  blur: 0.8
});

Props / Options

The LiquidGlassOptions interface includes:

PropTypeDefaultDescription
widthnumber0 (auto)Override element width for map computation
heightnumber0 (auto)Override element height
radiusnumber | nullnull (auto)Corner radius in px (auto-detected from CSS if null)
bezelWidthnumber20Thickness of the refracting bezel in px
glassThicknessnumber80Virtual glass depth — controls refraction strength
refractiveIndexnumber1.5Index of refraction (1.0 = none, 2.0 = strong)
profile'convexSquircle' | 'convexCircle' | 'concave' | function'convexSquircle'Surface curvature profile
blurnumber0.5Pre-displacement Gaussian blur (stdDeviation)
saturationnumber1.3Color saturation boost
specularSlopenumber0.8Specular highlight intensity (0–1)
filterMode'screen' | 'composite''screen'How specular layer is blended

Return Value — LiquidGlassHandle

MemberTypeDescription
elementElementThe target DOM element
refresh()() => thisRebuild maps (call after resize if ResizeObserver unavailable)
destroy()() => voidRemove effect and clean up
on('resize', cb)EventEmitterFired when ResizeObserver triggers a rebuild
on('destroy', cb)EventEmitterFired on destroy()

On this page