Button
A button made of glass. Clear glass bends the page behind it; tinted glass takes your background colour.
Latest changeNewv2.0.0Cohesion: two buttons that come close melt into one body of glass and share the light of a press.
- v2.0.0NewCohesion: two buttons that come close melt into one body of glass and share the light of a press.
- v2.0.0NewPull: hold and drag a button and it stretches like rubber, then springs back. On by default;
pull={false}keeps it in place. - v1.0.0NewFirst release, in
@vitrumui/react/button. - All changes →
Use it for
- One action: a call to action, a toolbar button, a link that looks like a button.
- Clear glass over imagery or colour, where the bend shows.
Not for
- An async action whose result should show on the button: use GlassActionButton.
- Choosing between options: use GlassTabs.
- Every button of a dense form: keep the glass for the action that matters.
Installation
npm install @vitrumui/reactUsage
import { GlassButton } from '@vitrumui/react/button'
<GlassButton>Get started</GlassButton>
<GlassButton material="tinted" className="bg-sky-500 text-white">Save</GlassButton>
<GlassButton asChild>
<Link href="/docs">Read the docs</Link>
</GlassButton>Examples
materialtintsizeiconpullHold any button and pull it towards its neighbour: under 6 px the two melt into one body of liquid glass, and press light flows across the bridge. Set pull={false} to keep a button pinned in place.
Colour tinted glass with a normal class such as bg-sky-500; the glass paints itself in that colour and adds light and shadow. A border-* class becomes the glass rim.
Free and open source
MIT licensed. Copy the files, they are yours.
With asChild the glass goes on your single child element instead of a <button>: an <a>, a Next.js <Link>, a TanStack Router <Link>. Your element keeps its own props and navigation.
TROMSØ · WINTER SEASON
Chase the northern lights
Clear glass repaints what lies behind it: background colours, gradients and images, <img> and <video> the way the page crops them (object-fit), text, inline SVG icons and backdrop blur, in their stacking order. Shadows, ::before/::after and conic gradients are not painted.
An image from another origin must be served with CORS headers (image CDNs usually send them): the glass requests it again with CORS, and leaves it out if the server refuses.
The glass takes the corners of the element it sits on. Add a rounded-* class and the lens, its rim and its shadow follow; the bend stays as deep as on a pill.
API reference
| Prop | Type | Default |
|---|---|---|
materialClear bends the page; tinted uses the background colour. | 'clear' | 'tinted' | 'clear' |
sizeHeight 32, 40, 48 or 64 px. | 'sm' | 'md' | 'lg' | 'xl' | 'md' |
iconAn icon element (e.g. a lucide-react icon). | ReactNode | — |
iconPositionWhich side the icon sits on. | 'start' | 'end' | 'end' |
tintClear glass only: how much tint covers the backdrop (0–1). | number | 0.6 |
pullHold and drag to pull the button through a rubber band and melt into nearby buttons. | boolean | true |
asChildPut the glass on the single child element instead of a | boolean | false |
…restPassed to the element ( | button attributes | — |
Accessibility
- A real
<button>(or your own element withasChild): focus, Enter and Space work as usual. - The glass canvas is
aria-hidden; only your label is announced. - Icon-only buttons need an
aria-label.