Glass Bubble
betaA draggable glass lens that refracts the content under it, with a specular highlight and chromatic fringing.
- Effects & motion
- 1 file
- 1 npm package
- Accessibility notes
- Draws on a canvas
pnpm dlx @dowel-ui/cli add glass-bubblenpm packages installed: radix-ui.
import { GlassBubble } from "@/components/ui/glass-bubble";Default
Gallery
Controlled
Disabled
Right To Left
<GlassBubble>
| Prop | Type | Default |
|---|---|---|
bendLens curvature, 0-100: how strongly it magnifies and bends. | number | 70 |
defaultValueStarting position (uncontrolled). Defaults to the centre. | GlassBubbleValue | CENTRE |
disabledStops dragging and keyboard nudging. | boolean | false |
fringeChromatic spread at the rim, 0-40. | number | 18 |
lensWhich lens to draw. "auto" uses the SVG refraction in Chromium and the blur fallback elsewhere; the others force one (the SVG lens renders as plain glass where it is unsupported). | GlassBubbleLens | "auto" |
onValueChangeCalled with the new position as the bubble is dragged or nudged. | (value: GlassBubbleValue) => void | — |
sizeBubble diameter in px, 80-240. | number | 132 |
valuePosition in percent of travel (controlled). | GlassBubbleValue | — |
childrenThe content under the lens (an image, a gradient, anything). | ReactNode | — |
Plus every attribute of <div> except defaultValue, onChange.
10/10
checks passed
- Tested — passes
- axe assertion — passes
- Keyboard tested — passes
- Storybook examples — passes
- Accessibility documented — passes
- Semantic tokens only — passes
- Motion from tokens — passes
- className merged — passes
- Visible focus — passes
- No fixed widths — passes