Liquid glass card
A plain Haze card surface (bordered, flat, no blur or glow) with an optional header, body slot and footer, shown as a compact music player.
pnpm dlx shadcn@latest add @haze/liquid-glass-card---
import { cn } from "../../../lib/haze/utils";
type CardPadding = "none" | "sm" | "md" | "lg";
interface Props {
/** Optional id for the card element. */
id?: string;
eyebrow?: string;
title?: string;
description?: string;
padding?: CardPadding;
interactive?: boolean;
headingLevel?: 2 | 3 | 4;
class?: string;
}
const {
id,
eyebrow,
title,
description,
padding = "md",
interactive = false,
headingLevel = 3,
class: className,
} = Astro.props;
const Heading = ({ 2: "h2", 3: "h3", 4: "h4" } as const)[headingLevel];
const hasAction = Astro.slots.has("action");
const hasFooter = Astro.slots.has("footer");
const hasBody = Astro.slots.has("default");
const resolvedEyebrow = eyebrow ?? (hasBody ? undefined : "Workspace");
const resolvedTitle = title ?? (hasBody ? undefined : "Edge network");
const resolvedDescription =
description ?? (hasBody ? undefined : "A plain card surface with an optional header, body and footer.");
const hasHeader = Boolean(resolvedEyebrow || resolvedTitle || resolvedDescription || hasAction);
const pad: Record<CardPadding, string> = {
none: "",
sm: "p-4 gap-3",
md: "p-5 gap-4",
lg: "p-6 gap-5",
};
const footerPad: Record<CardPadding, string> = {
none: "px-5 py-3.5",
sm: "px-4 py-3",
md: "px-5 py-3.5",
lg: "px-6 py-4",
};
---
<article
id={id}
class={cn(
"flex min-w-0 flex-col overflow-hidden rounded-xl border border-border bg-card text-card-foreground",
interactive &&
"transition-colors duration-200 ease-snappy motion-reduce:transition-none hover:border-border-strong has-focus-visible:border-border-strong",
className,
)}
>
<div class={cn("flex min-w-0 flex-1 flex-col", pad[padding])}>
{
hasHeader && (
<div class="flex min-w-0 items-start justify-between gap-3">
<div class="grid min-w-0 gap-1">
{resolvedEyebrow && (
<p class="text-xs/4 font-medium tracking-[0.02em] text-muted-foreground uppercase">{resolvedEyebrow}</p>
)}
{resolvedTitle && (
<Heading class="text-[1.0625rem]/6 font-medium tracking-[-0.01em] text-card-foreground wrap-anywhere">
{resolvedTitle}
</Heading>
)}
{resolvedDescription && (
<p class="text-[0.8125rem]/5 text-muted-foreground text-pretty wrap-anywhere">{resolvedDescription}</p>
)}
</div>
{hasAction && (
<div class="shrink-0">
<slot name="action" />
</div>
)}
</div>
)
}
<div class="min-w-0 text-[0.8125rem]/5 text-card-foreground">
{
hasBody ? (
<slot />
) : (
<dl class="grid grid-cols-2 gap-3 rounded-lg bg-muted p-3">
<div class="grid min-w-0 gap-0.5">
<dt class="text-xs/4 text-muted-foreground">Latency</dt>
<dd class="font-medium text-foreground tabular-nums">11.4 ms</dd>
</div>
<div class="grid min-w-0 gap-0.5">
<dt class="text-xs/4 text-muted-foreground">Edge nodes</dt>
<dd class="font-medium text-foreground tabular-nums">32 active</dd>
</div>
</dl>
)
}
</div>
</div>
{
hasFooter && (
<div class={cn("border-t border-border text-[0.8125rem]/5 text-muted-foreground", footerPad[padding])}>
<slot name="footer" />
</div>
)
}
</article>When to use
- A highlighted widget or feature card needs a flat bordered surface with an optional eyebrow, title, action and footer
- You want a reusable card slot container that matches the Haze neutral surfaces in dark and light themes
When not to use
- A plain content box with no header or footer structure is enough. Use card.
- The surface is a media frame. Use frame.
Installation
Add the Haze registry to components.json once, then install Liquid glass card with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/liquid-glass-cardnpx shadcn@latest add @haze/liquid-glass-cardyarn dlx shadcn@latest add @haze/liquid-glass-cardbunx --bun shadcn@latest add @haze/liquid-glass-cardFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | – | Optional id on the card element. |
| eyebrow | string | – | Optional uppercase label rendered above the title; defaults to a sample label when no default slot is provided. |
| title | string | – | Optional card heading text; defaults to a sample title when no default slot is provided. |
| description | string | – | Optional supporting summary text under the heading. |
| padding | "none" | "sm" | "md" | "lg" | "md" | Internal spacing density for the card body and footer. |
| interactive | boolean | false | Strengthens the border on hover and focus when the card acts as an interactive surface. |
| headingLevel | 2 | 3 | 4 | 3 | Heading level for the optional card title. |
| class | string | – | Additional classes on the outer card element. |
Accessibility
- Uses solid card tokens with no blur or translucency, so copy keeps full contrast on any backdrop.
- The demo scrubber is a native range input with an accessible label; play, previous and next are real buttons.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI component "Liquid glass card" with `npx shadcn@latest add @haze/liquid-glass-card`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import LiquidGlassCard from "@/components/haze/ui/liquid-glass-card.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/liquid-glass-card.md
Customize with real content
Adapt the Haze liquid-glass-card ui for our product. Replace the demo values of these props with our real content: id, eyebrow, title, description, padding, interactive, headingLevel, class. Keep the layout, the heading level rules and these accessibility details: Uses solid card tokens with no blur or translucency, so copy keeps full contrast on any backdrop. The demo scrubber is a native range input with an accessible label; play, previous and next are real buttons. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using liquid-glass-card, check it fits: use it when a highlighted widget or feature card needs a flat bordered surface with an optional eyebrow, title, action and footer; you want a reusable card slot container that matches the haze neutral surfaces in dark and light themes. Avoid it when a plain content box with no header or footer structure is enough. use card.; the surface is a media frame. use frame.. Alternatives: @haze/card, @haze/bento-tile, @haze/frame.
Dependencies
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.