Effects
Glass Lens
A draggable magnifier whose glass rim bends the content beneath it.
pnpm dlx shadcn@4.14.1 add @glassyui/glass-lensPreview
A closer look at the details.
Demos ready. Update 0.
Installation
First add the exact @glassyui mapping to components.json as shown in Getting Started. Then run the pinned item command:
pnpm dlx shadcn@4.14.1 add @glassyui/glass-lensWhat this installs10 files, 1 package
Direct registry declarations
These values belong to @glassyui/glass-lens itself in registry.json.
Package dependencies
clsx
Registry dependencies
@glassyui/glass-surface
File targets
components/glassyui/glass-lens.tsx
Complete installed closure
This follows every namespaced registry dependency recursively and de-duplicates the packages and target files installed with this item.
Package dependencies
clsx
Installed files
components/glassyui/glass-lens.tsxcomponents/glassyui/glass-surface.tsxcomponents/glassyui/lib/merge-refs.tscomponents/glassyui/lib/refraction-map.tscomponents/glassyui/lib/use-refraction-filter.tsxcomponents/glassyui/lib/scene-context.tscomponents/glassyui/glass-provider.tsxcomponents/glassyui/liquid-filters.tsxcomponents/glassyui/lib/preferences.tscomponents/glassyui/styles/liquid.css
Usage
Save this as lens-example.tsx. It is the complete example shown above, including its artwork.
'use client';
import { GlassLens } from '@/components/glassyui/glass-lens';
export function LensExample() {
return (
<GlassLens
defaultPosition={{ x: 0.62, y: 0.5 }}
size={116}
style={{ width: '100%', maxWidth: 440, height: 240, borderRadius: 22 }}
zoom={1.7}
>
<div
style={{
display: 'grid',
placeItems: 'center',
boxSizing: 'border-box',
width: '100%',
height: '100%',
padding: 24,
background:
'linear-gradient(#ffffff20 1px, transparent 1px) 0 0 / 20px 20px, linear-gradient(90deg, #ffffff20 1px, transparent 1px) 0 0 / 20px 20px, radial-gradient(ellipse at 90% 100%, #9b341e, transparent 65%), linear-gradient(135deg, #482015, #792b1c 55%, #3c1e16)',
color: '#fff',
textAlign: 'center',
}}
>
<p
style={{
maxWidth: '12ch',
margin: 0,
fontSize: 30,
fontWeight: 700,
lineHeight: 1.12,
letterSpacing: '-0.025em',
}}
>
A closer look at the details.
</p>
</div>
</GlassLens>
);
}
After configuring the registry, install every component this example uses:
pnpm dlx shadcn@4.14.1 add @glassyui/glass-lensExamples
import { LensExample } from "./lens-example";
export default function Page() {
return <LensExample />;
}API
GlassLensStage that renders its children plus a draggable magnifier over them.
childrenContent to magnify. It renders twice, so give it its own background and avoid ids.
sizeLens diameter in pixels. Defaults to 160.
zoomMagnification inside the lens. Defaults to 1.6.
defaultPositionStarting centre as fractions of the stage. Defaults to the middle.
labelAccessible name of the lens. Defaults to Magnifier.
Notes
Browsers
The rim bends through an SVG filter on the magnified copy, which every current engine draws. Reduced motion and reduced transparency keep a plain magnifier.
Keyboard
The lens is focusable. Arrow keys move it 10 pixels, or 50 with Shift.
Accessibility
Keep the Radix-backed semantics intact and preserve visible labels, focus states, and keyboard operation when copying the source.
Performance
Use provider quality preferences for dense app screens. Reserve strong refraction for hero or showcase surfaces.