Skip to content

Components

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.
  1. v1.6.12ImprovedA 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.
  2. v1.5.1ImprovedReturn a Promise from onClick and the button stays pending until it settles: no second press, and screen readers are told.
  3. v1.3.6ImprovedThe Play example is fully clear (tint={0}): only the bent grid shows through.
  4. v1.1.0Improvedsize="xl": a 64 px glass button for the one action a page is about.
  5. 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.
  6. 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.
  7. All changes →
glass-button-clear.tsx

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.json

The 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

app.tsx
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

PropTypeDefault
material

Clear bends the page; tinted uses the background colour.

'clear' | 'tinted''clear'
size

Height 32, 40, 48 or 64 px.

'sm' | 'md' | 'lg' | 'xl''md'
icon

An icon element (e.g. a lucide-react icon).

ReactNode—
iconPosition

Which side the icon sits on.

'start' | 'end''end'
tint

Clear glass only: how much tint covers the backdrop (0–1).

number0.6
asChild

Put the glass on the single child element instead of a <button>.

booleanfalse
pull

Hold and drag: the button follows the pointer a little way, stretches along the pull and swings back when let go.

booleantrue
…rest

Passed to the button: onClick, disabled, type, and UI SDK's pendingAnnouncement and focusableWhenDisabled.

button attributes—

Accessibility

  • A real <button> (or your own element with asChild): 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.