Components
Card
Content surface for panels, tiles, and settings groups.
Composition
Panel anatomy
- <Card>
- <CardHeader>
- <CardTitle />
- <CardDescription />
- <CardAction />
- <CardContent />
- <CardFooter />
- <CardHeader>
Clickable card
CardLink turns the whole card into its hit area: the card paints --cui-card-hover-background on hover and the focus ring while the link has focus. It renders a button; pass render={<a href />} to navigate. Other buttons, links, inputs, and checkboxes in the card stay clickable above it.
- <Card>
- <CardHeader>
- <CardTitle>
- <CardLink />
- <CardDescription />
- <CardTitle>
- <CardContent />
- <CardHeader>
Installation
The Control UI source installs this component from src/registry/sources/control-ui/ui/card.tsx.
npx shadcn@latest add https://control-ui.dev/r/card.jsonRaw code
Primary installed source
"use client";
import { useRender } from "@base-ui/react/use-render";import type { ComponentProps, CSSProperties } from "react";import type { RenderProp } from "@/components/control-ui/control-props";import type { CardKnobStyle } from "@/components/control-ui/knob-contracts/card-knobs";import { cn } from "@/components/control-ui/lib/cn";
export type CardVariant = "default" | "sectioned";
export type CardSize = "default" | "sm";
export type CardProps = Omit<ComponentProps<"div">, "style"> & { style?: CSSProperties & CardKnobStyle } & { variant?: CardVariant; size?: CardSize;};
export type CardHeaderProps = ComponentProps<"div"> & { style?: CSSProperties & CardKnobStyle };
export type CardTitleProps = Omit<ComponentProps<"div">, "style"> & { render?: RenderProp<ComponentProps<"div">>; style?: CSSProperties & CardKnobStyle;};
export type CardDescriptionProps = ComponentProps<"div"> & { style?: CSSProperties & CardKnobStyle };
export type CardActionProps = ComponentProps<"div"> & { style?: CSSProperties & CardKnobStyle };
export type CardContentProps = ComponentProps<"div"> & { style?: CSSProperties & CardKnobStyle };
export type CardFooterProps = ComponentProps<"div"> & { style?: CSSProperties & CardKnobStyle };
export type CardLinkProps = Omit<ComponentProps<"button">, "style"> & { render?: RenderProp<ComponentProps<"button">>; style?: CSSProperties & CardKnobStyle;};
export function Card({ variant = "default", size = "default", className, ...props }: CardProps) { return ( <div data-control-ui="card" data-control-family="card" data-slot="root" data-surface="panel" data-variant={variant} data-size={size} className={cn("flex flex-col", className)} {...props} /> );}
export function CardHeader({ className, ...props }: CardHeaderProps) { return ( <div data-control-ui="card" data-control-family="card" data-slot="header" className={cn("grid auto-rows-min grid-rows-[auto_auto] items-start has-[>[data-slot=action]]:grid-cols-[1fr_auto]", className)} {...props} /> );}
export function CardTitle({ render, ...props }: CardTitleProps) { return useRender({ defaultTagName: "div", render, props: { ...props, "data-control-ui": "card", "data-control-family": "card", "data-slot": "title" }, });}
export function CardDescription({ className, ...props }: CardDescriptionProps) { return <div data-control-ui="card" data-control-family="card" data-slot="description" className={className} {...props} />;}
export function CardAction({ className, ...props }: CardActionProps) { return ( <div data-control-ui="card" data-control-family="card" data-slot="action" className={cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className)} {...props} /> );}
export function CardContent({ className, ...props }: CardContentProps) { return <div data-control-ui="card" data-control-family="card" data-slot="content" className={className} {...props} />;}
export function CardFooter({ className, ...props }: CardFooterProps) { return ( <div data-control-ui="card" data-control-family="card" data-slot="footer" className={cn("flex items-center [.border-t]:pt-(--cui-card-gap)", className)} {...props} /> );}
export function CardLink({ render, ...props }: CardLinkProps) { return useRender({ defaultTagName: "button", render, props: { type: render ? undefined : "button", ...props, "data-control-ui": "card", "data-control-family": "card", "data-slot": "link", "data-focus-ring": "none", }, });}
Knobs
Typed custom properties the recipe paints with. Set one on the root — style, a utility class, or a skin — and every slot inherits it.
| Knob | Syntax | Default |
|---|---|---|
--cui-card-radius | <length-percentage> | var(--radius-panel) |
--cui-card-background | <color> | var(--card) |
--cui-card-foreground | <color> | var(--card-foreground) |
--cui-card-section-border-color | <color> | oklch(from var(--border) l c h / 0.7) |
--cui-card-hover-background | <color> | var(--hover-fill) |
--cui-card-border-color | <color> | var(--border) |
--cui-card-border-width | <length> | var(--control-rim-width) |
--cui-card-shadow | * | var(--shadow-sm) |
--cui-card-backdrop-filter | * | none |
--cui-card-padding-block | <length-percentage> | calc(var(--spacing) * 6) |
--cui-card-padding-inline | <length-percentage> | calc(var(--spacing) * 6) |
--cui-card-gap | <length-percentage> | calc(var(--spacing) * 6) |
--cui-card-title-font-size | <length-percentage> | 1em |