Surfaces
Card
shadcn's Card API on glass: header, title, description, action, content, footer.
Installation
pnpm dlx shadcn@latest add https://glasscn.app/r/card.jsonOr with the namespace set up: shadcn add @glasscn/card
Props
| Prop | Type | Default |
|---|---|---|
| intensity | "default" | "strong" | "subtle"How much frost: the fill's opacity over the blur. | "default" |
| tint | "none" | "primary" | "destructive"Mixes a colour into the frost via --glass-bg. | "none" |
| elevation | "raised" | "flat"Drop shadow on or off (--glass-elevation). | "raised" |
| size | "default" | "sm"Padding and corner scale. | "default" |
Parts: CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter — same as shadcn's Card.
Source
components/glass/card.tsx
import * as React from "react"
import { cn } from "cn"
import { glassVariants, type GlassVariantProps } from "@/lib/glass-variants"
/** shadcn's Card API on a glass pane. Same parts, same props — swap the import. */
function Card({
className,
size = "default",
intensity,
tint,
elevation,
...props
}: React.ComponentProps<"div"> & GlassVariantProps & { size?: "default" | "sm" }) {
return (
<div
data-slot="card"
data-size={size}
className={cn(
glassVariants({ intensity, tint, elevation }),
"group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-surface py-(--card-spacing) text-sm text-card-foreground [--card-spacing:calc(1.25rem*var(--glass-density))] has-data-[slot=card-footer]:pb-0 data-[size=sm]:[--card-spacing:calc(1rem*var(--glass-density))] data-[size=sm]:rounded-surface-sm data-[size=sm]:has-data-[slot=card-footer]:pb-0",
className
)}
{...props}
/>
)
}
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-header"
className={cn(
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",
className
)}
{...props}
/>
)
}
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-title"
className={cn("type-glass-heading text-base group-data-[size=sm]/card:text-sm", className)}
{...props}
/>
)
}
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
return <div data-slot="card-description" className={cn("text-sm text-muted-foreground", className)} {...props} />
}
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-action"
className={cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className)}
{...props}
/>
)
}
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
return <div data-slot="card-content" className={cn("px-(--card-spacing)", className)} {...props} />
}
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-footer"
className={cn("flex items-center gap-2 border-t border-glass-border bg-fill/40 p-(--card-spacing)", className)}
{...props}
/>
)
}
export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent }