Skip to content

Components

Card

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.

Markdown
Latest changeImprovedv2.0.0Large frosted cards blur at a lower resolution first, so they cost much less to draw.
  1. v2.0.0ImprovedLarge frosted cards blur at a lower resolution first, so they cost much less to draw.
  2. v1.0.0NewFirst release, in @vitrumui/react/card.
  3. 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

npm install @vitrumui/react
Peer: React 19

Usage

app.tsx
import { GlassCard } from '@vitrumui/react/card'

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

Examples

Widgets over a wallpaper
glass-card-widgets.tsx

420/600

Move · kcal

Phone82%

Earbuds64%

Watch18%

Now playing

Slow Liquid

Glasswork

1:12-2:04

Over a still backdrop, like the wallpaper here, the card needs no live. Like every glass in the kit it repaints only when something changes, and draws nothing at rest. Turn live on only when content moves behind the card, as with the rows of colour above: the card then draws every frame while it is on screen.

The rim pulls what is behind towards the card's centre, by 6.5% of the viewport, fading over half the card, so type and colour stretch along the edge. The face then frosts the bent picture with a 5 px blur (blur) and covers it with a tint (tint): 70% white on a light page, 70% black on a dark one. A 1.3 px white line runs inside the rim; there is no colour split or light, only a soft drop shadow. Unlike a button, the card stays still under the pointer: it holds content, it does not swell. Size and padding come from your classes, and the glass takes the card's corners: rounded-[28px] by default, any rounded-* class to change them. Text on clear glass follows the tone the glass ends up (data-vt-tone), so it reads on light and dark backdrops. For a coloured card, use material="tinted" with a bg-* class.

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.