Skip to content
Effects Fancy Stable

LiquidGlass

.md

Glass-like visual effect using SVG filters for chromatic displacement

Available for Svelte 5, React, and Vue 3.

Preview

Installation

pnpm add fancy-ui-svelte
import { LiquidGlass } from "fancy-ui-svelte";

Usage

svelte
<script lang="ts">
	import { LiquidGlass } from "fancy-ui-svelte";
</script>

<div class="relative h-[440px] w-full overflow-hidden rounded-lg border bg-[#fafafa]">
	<div class="absolute inset-0 overflow-y-auto" style="scrollbar-width: none;">
		<!-- Hero -->
		<div class="flex min-h-[420px] flex-col items-center justify-center px-8 pt-24 text-center">
			<span
				class="rounded-full border border-gray-200 bg-white px-3 py-1 text-xs font-medium text-gray-500"
			>
				Now available for macOS
			</span>
			<h1 class="mt-5 max-w-md text-4xl leading-tight font-semibold tracking-tight text-gray-900">
				Your UI, at the speed of thought.
			</h1>
			<p class="mt-4 max-w-sm text-sm text-gray-500">
				FancyOS turns your voice into polished interfaces. Speak naturally, ship beautifully.
			</p>
			<div class="mt-6 flex items-center gap-3">
				<span class="rounded-full bg-gray-900 px-5 py-2.5 text-sm font-semibold text-white">
					Download
				</span>
				<span class="px-3 py-2.5 text-sm font-medium text-gray-600">Watch demo</span>
			</div>
		</div>

		<!-- Colorful sections to scroll behind the nav -->
		<div class="space-y-6 px-8 pb-12">
			{#each Array(6) as _, i}
				<div
					class="flex h-32 items-end rounded-3xl p-5"
					style="background: linear-gradient(120deg, hsl({210 + i * 40}, 75%, 62%), hsl({250 +
						i * 40}, 70%, 55%));"
				>
					<p class="text-sm font-semibold text-white/90">Feature {i + 1}</p>
				</div>
			{/each}
		</div>
	</div>

	<!-- Fixed pill nav -->
	<div class="pointer-events-none absolute inset-x-0 top-4 z-10 flex justify-center px-6">
		<div class="pointer-events-auto w-full max-w-lg">
			<LiquidGlass radius={9999} containerClass="w-full">
				<nav class="flex w-full items-center justify-between px-6 py-3">
					<span class="flex items-center gap-1.5 text-sm font-bold tracking-tight text-gray-900">
						<span class="inline-block size-4 rounded-full bg-gray-900"></span>
						FancyOS
					</span>
					<div class="flex items-center gap-5 text-[13px] font-medium text-gray-800">
						<span class="hidden sm:inline">Manifesto</span>
						<span class="hidden sm:inline">Pricing</span>
						<span class="hidden sm:inline">Blog</span>
						<span class="rounded-full bg-gray-900 px-3.5 py-1.5 text-xs font-semibold text-white">
							Download
						</span>
					</div>
				</nav>
			</LiquidGlass>
		</div>
	</div>
</div>

Examples

Basic Usage

Landing Page Navbar

Landing page with a liquid glass pill navigation.

Props

PropTypeDefaultDescription
radius number16Border radius in pixels
border number0.07Border thickness as fraction of min dimension
lightness number50Background 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 number0.93Background fill alpha
blur number11Blur applied to the background fill layer
rOffset number0Red channel displacement offset
gOffset number10Green channel displacement offset
bOffset number20Blue channel displacement offset
scale number-180Displacement scale
frost number0.05Frosted glass opacity
fallbackBlur number20Backdrop blur in pixels for the Safari fallback
fallbackSaturation number180Backdrop saturation percentage for the Safari fallback
containerClass string""CSS classes for the outer container

Slots

SlotDescription
children Content rendered inside the glass effect