Liquid glass
for the web.
Glassform ships Svelte and React components with shared glass styles and photo-backed refraction.
Installation
Svelte
Run in a project configured for shadcn-svelte. Its installer requires Tailwind.
bunx shadcn-svelte@1.8.1 add https://glassform.pages.dev/r/glassform.jsonReact
Run in a project configured for shadcn.
bunx shadcn@latest add https://glassform.pages.dev/r/glassform-react.jsonBoth commands copy the source into the glassform folder under your components
alias. Glassform uses plain CSS. For a manual install, copy the files from the registry item.
Compose a panel
These examples put a panel inside a LensStage. Set photo.src to your backdrop image. Compare both lens modes.
<script lang="ts">
import GlassProvider from '$lib/components/glassform/GlassProvider.svelte';
import GlassPanel from '$lib/components/glassform/GlassPanel.svelte';
import GlassButton from '$lib/components/glassform/GlassButton.svelte';
import LensStage from '$lib/components/glassform/LensStage.svelte';
</script>
<GlassProvider appearance="system">
<LensStage photo={{ src: '/images/backdrop.webp' }}>
<GlassPanel material="lens">
<h2>Display settings</h2>
<GlassButton material="embedded">Apply</GlassButton>
</GlassPanel>
</LensStage>
</GlassProvider>import {
GlassProvider, GlassPanel, GlassButton, LensStage
} from "@/components/glassform/glassform";
export function SettingsPanel() {
return (
<GlassProvider appearance="system">
<LensStage photo={{ src: "/images/backdrop.webp" }}>
<GlassPanel material="lens">
<h2>Display settings</h2>
<GlassButton material="embedded">Apply</GlassButton>
</GlassPanel>
</LensStage>
</GlassProvider>
);
}Components
Core
| Component | Props and usage |
|---|---|
GlassProvider | Scopes appearance, blur, and Solid mode. Nested providers inherit settings they omit. appearance: system | light | dark · blur: number (px) · solid: boolean · as: div | main | section |
LensStage | Supplies a photo backdrop and automatically applies optical refraction to Lens surfaces inside it. photo: { src, srcset?, sizes?, alt? } · blur: number (px) · ripple: number · refract: boolean · trackPointer: boolean |
Surfaces
| Component | Props and usage |
|---|---|
GlassSurface | The base surface with a shared rim and corner radius. Defaults to Lens. material: lens | solid |
GlassPanel | A padded GlassSurface for grouping content and controls. Accepts the same props as GlassSurface. material: lens | solid · --glass-panel-padding |
GlassAvatar | src, alt, fallback initials |
GlassKbd | Keyboard shortcut content |
GlassScrollArea | label, --glass-scroll-max-block-size |
Controls
| Component | Props and usage |
|---|---|
GlassButton | A native button that defaults to type="button" and the Solid material. Use embedded inside a Panel to share its blur. material: solid | lens | embedded · native button attributes and events |
GlassInput | Native input attributes, bind:value |
GlassTextarea | Native textarea attributes, bind:value |
GlassSelect | options, bind:value |
GlassCheckbox | Native checkbox attributes, bind:checked |
GlassSwitch | Native checkbox attributes, bind:checked |
GlassSlider | min, max, step, bind:value |
GlassRadioGroup | label, name, options, bind:value |
GlassSegmentedControl | label, name, options, bind:value |
Everyday UI
Change the settings to see how Glassform controls work together on a Lens panel.
Use an id with a matching <label for> on individual controls.
Groups render their own legend. Share refraction by placing related controls in one Lens panel.
Theming
Set CSS custom properties on a Provider or an individual component. Use appearance="system" to follow the visitor's color preference. Set solid on a Provider for opaque
surfaces throughout its scope.
| Token | Purpose | Default |
|---|---|---|
--glass-blur | Backdrop blur radius | 4px |
--glass-tint | Translucent color behind the content | #ffffff14 |
--glass-rim | Surface border color | Theme-dependent |
--glass-radius | Surface corner radius | 24px |
--glass-panel-padding | Panel content inset | 16–32px |
--glass-button-radius | Button corner radius | 999px |
--glass-focus | Keyboard focus outline color | Theme-dependent |
--glass-motion | Button feedback duration | 130ms |
Lens rendering
Live backdrop blur
Use GlassSurface or GlassPanel with material="lens" to blur the page content behind it.
Image-backed refraction
Supply a photo to LensStage to bend the image through the Lens surfaces it
discovers inside.
- WebGL bends the backdrop with a displacement map. Set
trackPointerto enable pointer-driven highlights, orrefract={false}for a frosted finish. - Fallbacks use SVG displacement where supported, or CSS backdrop blur when an optical renderer is unavailable.
- Accessibility and performance Glassform uses opaque surfaces in forced colors and with reduced transparency. Group controls on one filtered surface where possible. Device performance is still being evaluated.