# LiquidGlass

> Glass-like visual effect using SVG filters for chromatic displacement.

- Package: `fancy-ui-react` (React 18/19 + Tailwind CSS v4)
- Category: Effects
- Tags: glass, effect, svg, filter, chromatic, displacement, blur
- Types: `LiquidGlassProps`
- Docs: https://fancy-ui.rama.app/docs/components/liquid-glass
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/react/src/components/liquid-glass

## Import

```tsx
import { LiquidGlass } from 'fancy-ui-react';
```

Setup (once per project): `npm install fancy-ui-react`, then put these lines in your main CSS file (the stylesheet import goes right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-react/tailwind.css";
```

and import the component styles once in the app entry: `import "fancy-ui-react/styles.css";`. Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in React; when one differs from the Svelte name, the Svelte name follows in parentheses. `class` becomes `className`, a callback takes the name the React port declares (`onclick` becomes `onClick`), snippets become `ReactNode` props (render functions when they take arguments) and the default snippet is `children`. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/react#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `radius` | `number` | `16` | Border radius in pixels |
| `border` | `number` | `0.07` | Border thickness as fraction of min dimension |
| `lightness` | `number` | `50` | Background lightness percentage |
| `displace` | `number` | — | Optional Gaussian blur on the displacement output |
| `blend` | `string` | `"difference"` | SVG blend mode for the displacement channels |
| `xChannel` | `"R" \| "G" \| "B"` | `"R"` | X displacement channel selector |
| `yChannel` | `"R" \| "G" \| "B"` | `"B"` | Y displacement channel selector |
| `alpha` | `number` | `0.93` | Background fill alpha |
| `blur` | `number` | `11` | Blur applied to the background fill layer |
| `rOffset` | `number` | `0` | Red channel displacement offset |
| `gOffset` | `number` | `10` | Green channel displacement offset |
| `bOffset` | `number` | `20` | Blue channel displacement offset |
| `scale` | `number` | `-180` | Displacement scale |
| `frost` | `number` | `0.05` | Frosted glass opacity |
| `fallbackBlur` | `number` | `20` | Backdrop blur in pixels for the Safari fallback |
| `fallbackSaturation` | `number` | `180` | Backdrop saturation percentage for the Safari fallback |
| `containerClass` | `string` | `""` | CSS classes for the outer container |

## Node props

| Prop | Description |
| --- | --- |
| `children` | Content rendered inside the glass effect |

## Example

```tsx
import { LiquidGlass } from "fancy-ui-react";

export function LiquidGlassExample() {
	return (
		<div className="relative flex h-[400px] w-full items-center justify-center overflow-hidden rounded-lg border">
			<div className="absolute top-1/4 left-1/4 h-72 w-72 -translate-x-1/2 -translate-y-1/2 rounded-full bg-violet-500/30 blur-3xl" />
			<div className="absolute right-1/4 bottom-1/3 h-64 w-64 rounded-full bg-cyan-500/30 blur-3xl" />
			<div className="absolute bottom-1/4 left-1/2 h-56 w-56 -translate-x-1/2 rounded-full bg-rose-500/25 blur-3xl" />

			<div className="relative z-10">
				<LiquidGlass radius={20} frost={0.05}>
					<div className="text-foreground flex min-h-16 w-full items-center justify-center px-12 py-4 text-base font-medium">
						Liquid Glass
					</div>
				</LiquidGlass>
			</div>
		</div>
	);
}
```
