Skip to content

Components

Button

A button made of glass. Clear glass bends the page behind it; tinted glass takes your background colour.

Markdown
Latest changeNewv2.0.0Cohesion: two buttons that come close melt into one body of glass and share the light of a press.
  1. v2.0.0NewCohesion: two buttons that come close melt into one body of glass and share the light of a press.
  2. 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.
  3. v1.0.0NewFirst release, in @vitrumui/react/button.
  4. 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

npm install @vitrumui/react
Peer: React 19

Usage

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

Every prop, side by side
glass-button-props.tsx
material
tint
size
icon
pull

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

Tinted colours and sizes
glass-button-tinted.tsx

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.

As a link (asChild)
glass-button-link.tsx

Free and open source

MIT licensed. Copy the files, they are yours.

Read the docs

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.

Over colour with a scrim
glass-button-scrim.tsx

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.

Square corners
glass-button-corners.tsx

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

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
pull

Hold and drag to pull the button through a rubber band and melt into nearby buttons. false keeps it pinned.

booleantrue
asChild

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

booleanfalse
…rest

Passed to the element (onClick, disabled, type…).

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.