Docs
Apple Liquid Glass

Apple Liquid Glass

Displays a supa Apple Liquid Glass using svg.

Apple Liquid Glass

Move the glass to see the effect

Installation

Copy and paste the Apple Liquid Glass code into your project.

API Reference

Props

PropTypeDefaultDescription
widthnumber300Width of the liquid glass element in pixels
heightnumber200Height of the liquid glass element in pixels
initialPosition{ x: number; y: number }centerInitial position of the glass element
borderRadiusnumber150Border radius of the glass element in pixels
classNamestring""Additional CSS classes to apply to the container
disabledbooleanfalseDisables dragging functionality when true
constrainToViewportbooleantrueConstrains movement within viewport boundaries
opacitynumber1Opacity of the glass element (0-1)
blurnumber0.25Blur intensity for backdrop filter in pixels
contrastnumber1.2Contrast adjustment for backdrop filter
brightnessnumber1.05Brightness adjustment for backdrop filter
saturatenumber1.1Saturation adjustment for backdrop filter
onDragStart(position: Position) => voidundefinedCallback fired when dragging starts
onDrag(position: Position) => voidundefinedCallback fired during dragging
onDragEnd(position: Position) => voidundefinedCallback fired when dragging ends
styleReact.CSSProperties{}Additional inline styles to apply

The component now supports full customization of appearance, behavior, and event handling, making it highly flexible for different use cases.

Usage

export default function Demo() {
  return (
    <div className="flex flex-col items-center justify-center w-full h-[600px]">
      <div className="text-center mb-12">
        <h1 className="text-4xl font-bold mb-4">Apple Liquid Glass</h1>
        <p className="text-lg">Move the glass to see the effect</p>
      </div>
      <div
        className="w-full h-full relative bg-cover bg-center brightness-120 rounded-lg"
        style={{
          backgroundImage: `url("https://img.buoucoding.com/image/2.jpg")`,
        }}
      >
        <LiquidGlass />
      </div>
    </div>
  )
}