Button
A button made of glass. Clear glass bends the page behind it; tinted glass takes your background colour.
Latest changeImprovedv1.6.12A new pull prop on Button and GlassLayer. A pointer that holds the glass and drags away pulls it after itself: it follows a little way through a rubber band, stretches along the pull and thins across it, and swings back like gel when let go. Small glass (up to 72 px) follows from the point it was pressed at, larger glass once the pointer is past its edge. It is for buttons, and on by default on all of them: Button, Action Button and Button Group (pull={false} on Button or GlassLayer keeps one in its place). No other glass is pulled. The engine does it; its numbers are PULL in engine.ts, and on: false there turns it off everywhere. The motion is that of Glass HQ's liquid-glass (MIT), ported onto the kit's engine.
- v1.6.12ImprovedA new
pullprop on Button and GlassLayer. A pointer that holds the glass and drags away pulls it after itself: it follows a little way through a rubber band, stretches along the pull and thins across it, and swings back like gel when let go. Small glass (up to 72 px) follows from the point it was pressed at, larger glass once the pointer is past its edge. It is for buttons, and on by default on all of them: Button, Action Button and Button Group (pull={false}on Button or GlassLayer keeps one in its place). No other glass is pulled. The engine does it; its numbers arePULLinengine.ts, andon: falsethere turns it off everywhere. The motion is that of Glass HQ's liquid-glass (MIT), ported onto the kit's engine. - v1.5.1ImprovedReturn a Promise from
onClickand the button stays pending until it settles: no second press, and screen readers are told. - v1.3.6ImprovedThe Play example is fully clear (
tint={0}): only the bent grid shows through. - v1.1.0Improved
size="xl": a 64 px glass button for the one action a page is about. - v1.1.0ImprovedThe clear-glass example is a larger button on a quiet grid and nothing else: the lines bending at its rim are what you see first.
- v1.1.0ImprovedThe square-corners example sits on fine diagonal lines instead of a blue grid, so the Press demo keeps the site’s only grid.
- 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
npx shadcn@latest add https://onemorethink.dev/r/button.jsonThe button underneath is UI SDK's, so Button needs @ui-sdk/core and @ui-sdk/react. Return a Promise from onClick and the button stays pending until it settles: it ignores further presses and says so to screen readers. The install command adds both packages at the exact version this was built on: UI SDK is in beta and its API may still change.
Usage
import { GlassButton } from '@/components/liquid-glass'
<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>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 |
asChildPut the glass on the single child element instead of a | boolean | false |
pullHold and drag: the button follows the pointer a little way, stretches along the pull and swings back when let go. | boolean | true |
…restPassed to the button: | 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.