Skip to content

Components

CardUpdated

A card made of frosted glass. Your content sits on it; its face blurs and tints whatever lies behind so the text stays readable, and its rim pulls it towards the centre.

Latest changeImprovedv2.0.4In the Card example the rows of colour run from one side of the stage to the other, with no padding at the sides, and fade in at both ends through an SVG mask instead of a progressive blur.
  1. v2.0.4ImprovedIn the Card example the rows of colour run from one side of the stage to the other, with no padding at the sides, and fade in at both ends through an SVG mask instead of a progressive blur.
  2. v2.0.3ImprovedA Card kept room under its glass for a drop shadow it does not cast (its shadow is CSS): close to half of its canvas was empty, and was still painted, uploaded, shaded and copied on every frame. Glass that casts no shadow now keeps no room for one. The rows that went were all empty.
  3. v2.0.3ImprovedGlass frosted all over never reads the page at full size: every reading is a few mip levels up. The page is now painted that much smaller to begin with (a quarter or a sixteenth of the pixels), so there is that much less to paint, upload and build mipmaps from, which counts most on a phone. A 176 px live card on a double-density screen sent 256,000 pixels of the page to the GPU on every frame and now sends 11,000. Against the full picture the glass differs by 3 levels in 255 at most.
  4. v2.0.2ImprovedThe frost of a Card is 32 readings of the page for every pixel of the glass, most of what the GPU does for it. On large frosted glass (a canvas of about 0.3 megapixels or more, so mostly on high-density screens) the frost is now worked out first, into a picture a half or a third of the size, and the glass reads it; along the rim it is still worked out in full. Measured on one GPU, that is about a fifth less GPU time on a 0.36 megapixel card and three quarters less on a 1.9 megapixel one. The two pictures differ by 5 levels in 255 at most; smaller cards are drawn exactly as before.
  5. v1.5.5FixedThe first example shows one card where two do not fit side by side, centred on the two rows of colour. On a phone the cards used to stack, and the rows ran through the gap between them.
  6. v1.3.4ImprovedA new example in place of the notification: an activity ring, a battery list and a now-playing card over a still wallpaper of plain CSS. It scales down to fit a phone.
  7. All changes →
glass-card-basic.tsx

Use it for

  • A small surface of content over colour, imagery or motion: a widget, a now-playing card, a summary.
  • One or two cards, where what is behind them is part of the design.

Not for

  • Long text and forms: the backdrop shows through. Use a plain card.
  • A card on a flat background: there is nothing to bend.
  • One clickable action: use GlassButton.

Installation

npx shadcn@latest add https://liquidglass.onemorethink.dev/r/card.json

Usage

app.tsx
import { GlassCard } from '@/components/liquid-glass'

<GlassCard className="w-64 p-5">
  <p className="font-semibold">Wednesday</p>
  <p className="text-sm opacity-60">Design review · 10:00</p>
</GlassCard>

// Something moves behind it: repaint what it bends every frame.
<GlassCard live className="size-44 p-4">…</GlassCard>

// Clearer glass: no frost, less tint.
<GlassCard blur={0} tint={0.3} className="w-64 p-5">…</GlassCard>

API reference

PropTypeDefault
children

The card's content.

ReactNode—
material

Clear bends what is behind; tinted uses the background colour.

'clear' | 'tinted''clear'
tint

Clear glass only: how much tint covers the backdrop (0–1): white on a light page, black on a dark one.

number0.7
blur

Clear glass only: how much the backdrop is frosted, in px like CSS blur(). 0 shows it sharp.

number5
live

Repaint the backdrop every frame, for content that moves behind the card.

booleanfalse
className

Size, padding, corners (rounded-*) and, for tinted glass, colour (bg-*).

string—
…rest

Passed to the <div> (role, aria-label, onClick…).

div attributes—

Accessibility

  • A plain <div>: when the card stands for one thing, name it (role="group" with an aria-label).
  • The glass canvas is aria-hidden; only your content is read.
  • Content that moves behind it should respect reduced motion: the rows above stop.