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 | sectionGlassform ships Svelte and React components with shared glass styles and photo-backed refraction.
Run this command from a Svelte project configured for shadcn-svelte.
bunx shadcn-svelte@1.8.1 add https://glassform.pages.dev/r/glassform.jsonThe CLI uses your components alias and installs the source in its glassform folder. The CLI requires Tailwind during installation. Glassform uses plain CSS. To install
manually, copy the files from the registry item. Open the registry item.
<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>Use your own backdrop image at the path passed to LensStage.
Run this command in a React project configured for shadcn. The files go under its components alias.
bunx shadcn@latest add https://glassform.pages.dev/r/glassform-react.jsonSupply a backdrop image to LensStage to enable the shared WebGL optics.
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>
);
}Scopes appearance, blur, and Solid mode. Nested providers inherit settings they omit.
appearance: system | light | dark · blur: number (px) · solid: boolean · as: div | main | sectionSupplies 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: booleanThe base surface with a shared rim and corner radius. Defaults to Lens.
material: lens | solidA padded GlassSurface for grouping content and controls. Accepts the same props as GlassSurface.
material: lens | solid · --glass-panel-paddingA 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 eventsBind a control’s value in Svelte and use native labels, validation, and form submission.
| Component | Props and usage |
|---|---|
GlassAvatar | src, alt, fallback initials |
GlassKbd | Keyboard shortcut content |
GlassScrollArea | label, --glass-scroll-max-block-size |
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 |
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.
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 |
Place material="lens" surfaces inside a LensStage and supply a
backdrop image once. The stage treats the image as the source for refraction and discovers
Lens surfaces automatically. Lens surfaces outside a stage use CSS backdrop blur.
trackPointer to enable pointer-driven highlights, or refract={false} for a frosted finish.