Liquid glass
A floating regular or clear lens with optical edge refraction, pointer illumination and optional light tracking. Dim bright media beneath clear controls.
Installation
pnpm dlx shadcn@latest add https://glasscn.app/r/liquid-glass.jsonReact Native (iOS, Android and web through react-native-web) — same parts and props:
pnpm dlx shadcn@latest add https://glasscn.app/r/native-liquid-glass.jsonOr with the namespace set up: shadcn add @glasscn-app/liquid-glass
Props
| Prop | Type | Default |
|---|---|---|
| variant | "regular" | "clear"Regular diffuses content. Clear is for media; dim bright media behind it separately. | "regular" |
| optics (web) | booleanEnable Chromium edge displacement. Other engines keep the CSS material. Native uses the OS effect and has no optics prop. | true |
| interactive | booleanElastic press response. Put accessible buttons inside the surface or use asChild. | false |
| followLight (web) | booleanPoint the rim toward a fine pointer; disabled under reduced motion. Native illumination belongs to the OS. | false |
For the whole app, install glass-effects and render <GlassEffects /> once near the root. It enhances floating controls and newly opened portals. LiquidGlass installs the shared runtime automatically.
The bounded convex-lens model is a glasscn web approximation. Apple does not publish its compositor shader or numeric material constants. Native uses regular or clear system glass untinted by default.
Source
"use client"
import * as React from "react"
import { cn } from "@/lib/glass-cn"
import { Glass } from "@/components/glass/glass"
import { GlassEffects } from "@/components/glass/glass-effects"
const subscribeHydration = () => () => {}
/** A floating lens. For clear glass, dim bright media underneath with Backdrop, not the lens. */
export function LiquidGlass({
variant = "regular",
optics = true,
followLight = false,
interactive = false,
className,
...props
}: Omit<React.ComponentProps<typeof Glass>, "variant" | "intensity"> & {
variant?: "regular" | "clear"
optics?: boolean
followLight?: boolean
interactive?: boolean
}) {
const hydrated = React.useSyncExternalStore(subscribeHydration, () => true, () => false)
return (
<>
<GlassEffects enabled={optics} />
<Glass
data-slot="liquid-glass"
data-liquid-surface=""
data-glass-ready={hydrated ? "" : undefined}
data-glass-optics={optics ? undefined : "off"}
data-glass-follow-light={followLight ? "" : undefined}
variant={variant === "clear" ? "liquid-clear" : "liquid"}
className={cn("glass-illuminate", interactive && "glass-press-liquid", className)}
{...props}
/>
</>
)
}
