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.
Latest change Improved v2.3.5 Card's edge is retuned. Light glass loses its line: the 0.5 px black hairline at 8% is gone, and the shadow alone sets the card off the page. Dark glass draws a brighter one, white at 45% and about 1 px wide in place of 8% at 0.5 px, with a faint dark outline on its very edge. The tint, the frost and the shadow are as they were. optics.borderAlpha sets your own line, on both.
- v2.3.5 Improved Card's edge is retuned. Light glass loses its line: the 0.5 px black hairline at 8% is gone, and the shadow alone sets the card off the page. Dark glass draws a brighter one, white at 45% and about 1 px wide in place of 8% at 0.5 px, with a faint dark outline on its very edge. The tint, the frost and the shadow are as they were.
optics.borderAlphasets your own line, on both. - v2.3.0 Improved A glass whose corners differ keeps each its own. The glass took the top left corner for all four; now
rounded-t-3xlon a Card, or any radius set corner by corner, is drawn as it is written. - v2.3.0 Improved Card's glass is whiter on a light page: its tint covers 85% in place of 60%, so what is on the card reads over any colour behind it. The dark card keeps its 62% grey, and a
tintof yours still applies to both. - v2.2.1 Improved Card has a new default glass, tuned in the lab beside Glisse's (MIT). The tint is lighter: 60% white on a light page and 62% of a dark grey (rgb(40 40 40)) on a dark one, in place of 70% white and black. The frost is 3 px in place of 5, what shows through is 1.5 times as vivid, and the rim's bend stays close to the edge instead of reaching half way in. The 1.3 px white line gives way to a 0.5 px hairline at 8%, black on light glass and white on dark.
tintandblurstill set your own, and atintof yours applies to both themes. - v2.2.1 Improved
GlassOpticshas a third way to bend,bendMode: 'bezel': straight in from the rim, as light bends through a rounded bezel, by Glisse's own formula (github.com/0kzh/glisse, MIT).bendDepthis then the bevel's width as a share of half the glass,refractionhow far it bends, andzoomandrimShinecome with it; a bevel as wide as half the glass makes a lens. No component uses it by default.optics.dark.tintColorgives dark glass a tint colour of its own. - v2.0.4 Improved In 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.
- All changes→
Istanbul
16°
Cloudy
H:19° L:15°
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-svelte@latest add https://liquidglass.pulse.city/r/card.jsonUsage
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
| Prop | Type | Default |
|---|---|---|
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 (0.85), a dark grey on a dark one (0.62). Yours applies to both. | number | 0.85 / 0.62 |
blur Clear glass only: how much the backdrop is frosted, in px like CSS | number | 3 |
live Repaint the backdrop every frame, for content that moves behind the card. | boolean | false |
className Size, padding, corners ( | string | — |
…rest Passed to the | div attributes | — |
Accessibility
- A plain
<div>: when the card stands for one thing, name it (role="group"with anaria-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.
Liquid Glass Svelte is open source and MIT licensed. If it saves you time, you can support the project.