# Card

> A surface component for grouping related content, with elevated, filled, outlined, horizontal, and framed layouts.

Canonical URL: https://taut-ui.com/docs/components/card

```tsx
import { Button } from "@/components/ui/button";
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";

export default function Particle() {
  return (
    <Card className="w-80">
      <CardHeader>
        <CardTitle>Project Update</CardTitle>
        <CardDescription>
          Your project has been successfully deployed to production.
        </CardDescription>
      </CardHeader>
      <CardContent>
        <p className="text-muted-foreground text-sm">
          All 42 tests passed. Build time: 1m 23s.
        </p>
      </CardContent>
      <CardFooter className="gap-2">
        <Button size="sm">View Details</Button>
        <Button size="sm" variant="ghost">
          Dismiss
        </Button>
      </CardFooter>
    </Card>
  );
}
```

## Installation [#installation]

**CLI**

```bash
npx shadcn@latest add https://taut-ui.com/r/card.json
```

**Manual**

- Install the following dependencies:

```bash
npm install @base-ui/react class-variance-authority
```

- Copy and paste the following code into your project.

```tsx title="components/ui/card.tsx"
"use client";

import { mergeProps } from "@base-ui/react/merge-props";
import { useRender } from "@base-ui/react/use-render";
import { cva, type VariantProps } from "class-variance-authority";
import type React from "react";
import { Ripple } from "@/lib/ripple";
import { cn } from "@/lib/utils";

export const cardVariants = cva(
  [
    "relative flex rounded-3xl text-card-foreground outline-none",
    "transition-shadow duration-200 ease-out motion-reduce:transition-none",
    "[button&,a&]:cursor-pointer [button&,a&]:text-start",
    "[button&,a&]:focus-visible:ring-2 [button&,a&]:focus-visible:ring-ring [button&,a&]:focus-visible:ring-offset-2 [button&,a&]:focus-visible:ring-offset-background",
    "[button&]:disabled:pointer-events-none [button&]:disabled:opacity-38",
  ],
  {
    defaultVariants: { orientation: "vertical", variant: "default" },
    variants: {
      orientation: {
        vertical: "flex-col",
        horizontal: "flex-row items-center gap-4 p-4",
      },
      variant: {
        default: "bg-muted dark:bg-card [button&,a&]:hover:bg-accent",
        elevated:
          "bg-card shadow-[0_0.0625rem_0.1875rem_rgb(0_0_0/0.2),0_0.25rem_0.5rem_0.1875rem_rgb(0_0_0/0.1)] [button&,a&]:hover:bg-accent",
        filled: "bg-muted dark:bg-card [button&,a&]:hover:bg-accent",
        outlined:
          "border border-border bg-background [button&,a&]:hover:bg-muted",
      },
    },
  },
);

export interface CardProps extends useRender.ComponentProps<"div"> {
  variant?: VariantProps<typeof cardVariants>["variant"];
  orientation?: VariantProps<typeof cardVariants>["orientation"];
  ripple?: boolean;
}

export function Card({
  className,
  variant,
  orientation = "vertical",
  ripple = false,
  render,
  children,
  ...props
}: CardProps): React.ReactElement {
  const defaultProps = {
    children: ripple ? (
      <>
        {children}
        <Ripple />
      </>
    ) : (
      children
    ),
    className: cn(cardVariants({ orientation, variant }), className),
    "data-orientation": orientation,
    "data-slot": "card",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export function CardMedia({
  className,
  render,
  ...props
}: useRender.ComponentProps<"div">): React.ReactElement {
  const defaultProps = {
    className: cn(
      "relative overflow-hidden rounded-3xl [&>img,&>video]:size-full [&>img,&>video]:object-cover",
      "in-data-[orientation=horizontal]:w-28 in-data-[orientation=horizontal]:shrink-0 in-data-[orientation=horizontal]:self-stretch in-data-[orientation=horizontal]:rounded-2xl",
      className,
    ),
    "data-slot": "card-media",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export function CardHeader({
  className,
  render,
  ...props
}: useRender.ComponentProps<"div">): React.ReactElement {
  const defaultProps = {
    className: cn(
      "grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 p-6 has-data-[slot=card-action]:grid-cols-[1fr_auto]",
      "in-[[data-slot=card]:has(>[data-slot=card-panel])]:pb-2",
      "in-data-[orientation=horizontal]:min-w-0 in-data-[orientation=horizontal]:flex-1 in-data-[orientation=horizontal]:p-0",
      className,
    ),
    "data-slot": "card-header",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export function CardTitle({
  className,
  size = "md",
  render,
  ...props
}: useRender.ComponentProps<"div"> & {
  size?: "md" | "lg";
}): React.ReactElement {
  const defaultProps = {
    className: cn(
      "font-heading font-semibold tracking-tight",
      size === "lg" ? "text-xl leading-7" : "text-lg leading-6",
      "in-data-[orientation=horizontal]:text-base",
      className,
    ),
    "data-slot": "card-title",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export function CardDescription({
  className,
  render,
  ...props
}: useRender.ComponentProps<"div">): React.ReactElement {
  const defaultProps = {
    className: cn("text-muted-foreground text-sm leading-5", className),
    "data-slot": "card-description",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export function CardAction({
  className,
  render,
  ...props
}: useRender.ComponentProps<"div">): React.ReactElement {
  const defaultProps = {
    className: cn(
      "col-start-2 row-span-2 row-start-1 inline-flex self-start in-data-[orientation=horizontal]:self-center justify-self-end",
      className,
    ),
    "data-slot": "card-action",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export function CardPanel({
  className,
  render,
  ...props
}: useRender.ComponentProps<"div">): React.ReactElement {
  const defaultProps = {
    className: cn(
      "flex-1 p-6 in-[[data-slot=card]:has(>[data-slot=card-header])]:pt-2 in-[[data-slot=card]:has(>[data-slot=card-footer])]:pb-2",
      className,
    ),
    "data-slot": "card-panel",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export function CardFooter({
  className,
  render,
  ...props
}: useRender.ComponentProps<"div">): React.ReactElement {
  const defaultProps = {
    className: cn(
      "flex items-center gap-2 p-6 in-[[data-slot=card]:has(>[data-slot=card-panel])]:pt-2",
      className,
    ),
    "data-slot": "card-footer",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export function CardFrame({
  className,
  render,
  ...props
}: useRender.ComponentProps<"div">): React.ReactElement {
  const defaultProps = {
    className: cn(
      "flex flex-col gap-1 rounded-3xl bg-muted p-1.5 text-card-foreground",
      "*:data-[slot=card]:rounded-xl *:data-[slot=card]:bg-card *:data-[slot=card]:shadow-none *:data-[slot=card]:transition-none",
      "*:last:data-[slot=card]:rounded-b-2xl *:first:data-[slot=card]:rounded-t-2xl",
      "*:data-[slot=card]:[button&,a&]:hover:bg-accent *:data-[slot=card]:[button&,a&]:hover:shadow-none",
      className,
    ),
    "data-slot": "card-frame",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export function CardFrameHeader({
  className,
  render,
  ...props
}: useRender.ComponentProps<"div">): React.ReactElement {
  const defaultProps = {
    className: cn(
      "grid auto-rows-min grid-rows-[auto_auto] items-center gap-x-4 gap-y-0.5 px-5 py-4 has-data-[slot=card-frame-action]:grid-cols-[1fr_auto]",
      className,
    ),
    "data-slot": "card-frame-header",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export function CardFrameTitle({
  className,
  render,
  ...props
}: useRender.ComponentProps<"div">): React.ReactElement {
  const defaultProps = {
    className: cn(
      "font-heading font-semibold text-xl leading-7 tracking-tight",
      className,
    ),
    "data-slot": "card-frame-title",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export function CardFrameDescription({
  className,
  render,
  ...props
}: useRender.ComponentProps<"div">): React.ReactElement {
  const defaultProps = {
    className: cn("text-muted-foreground text-sm leading-5", className),
    "data-slot": "card-frame-description",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export function CardFrameAction({
  className,
  render,
  ...props
}: useRender.ComponentProps<"div">): React.ReactElement {
  const defaultProps = {
    className: cn(
      "col-start-2 row-span-2 row-start-1 inline-flex self-center justify-self-end",
      className,
    ),
    "data-slot": "card-frame-action",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export function CardFramePanel({
  className,
  render,
  ...props
}: useRender.ComponentProps<"div">): React.ReactElement {
  const defaultProps = {
    className: cn("flex-1 rounded-2xl bg-card p-6", className),
    "data-slot": "card-frame-panel",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export function CardFrameFooter({
  className,
  render,
  ...props
}: useRender.ComponentProps<"div">): React.ReactElement {
  const defaultProps = {
    className: cn("flex items-center justify-between px-5 py-3", className),
    "data-slot": "card-frame-footer",
  };
  return useRender({
    defaultTagName: "div",
    props: mergeProps<"div">(defaultProps, props),
    render,
  });
}

export { CardPanel as CardContent, CardFramePanel as CardFrameContent };
```

- Update the import paths to match your project setup.

## Usage [#usage]

```tsx
import {
  Card,
  CardAction,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
```

```tsx
<Card>
  <CardHeader>
    <CardTitle>Card Title</CardTitle>
    <CardDescription>Card description goes here.</CardDescription>
  </CardHeader>
  <CardContent>
    <p>Card content.</p>
  </CardContent>
  <CardFooter>
    <Button size="sm">Action</Button>
  </CardFooter>
</Card>
```

## Examples [#examples]

### Elevated [#elevated]

```tsx
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";

export default function Particle() {
  return (
    <Card className="w-80" variant="elevated">
      <CardHeader>
        <CardTitle>Storage Usage</CardTitle>
        <CardDescription>14.2 GB of 20 GB used</CardDescription>
      </CardHeader>
      <CardContent>
        <p className="text-muted-foreground text-sm">
          Upgrade your plan anytime to unlock unlimited workspace storage.
        </p>
      </CardContent>
    </Card>
  );
}
```

### Outlined with Action [#outlined-with-action]

```tsx
import { Badge } from "@/components/ui/badge";
import {
  Card,
  CardAction,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";

export default function Particle() {
  return (
    <Card className="w-80" variant="outlined">
      <CardHeader>
        <CardTitle>Pro Plan</CardTitle>
        <CardDescription>Billed monthly</CardDescription>
        <CardAction>
          <Badge variant="success">Active</Badge>
        </CardAction>
      </CardHeader>
      <CardContent>
        <p className="text-muted-foreground text-sm">
          Includes priority support, custom domains, and team analytics.
        </p>
      </CardContent>
    </Card>
  );
}
```

### Horizontal [#horizontal]

```tsx
import { ArrowRightIcon, FolderIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
  Card,
  CardAction,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";

export default function Particle() {
  return (
    <Card className="w-80" orientation="horizontal" variant="filled">
      <div className="flex size-11 shrink-0 items-center justify-center rounded-2xl bg-card text-foreground">
        <FolderIcon className="size-5" />
      </div>
      <CardHeader>
        <CardTitle>Design Assets</CardTitle>
        <CardDescription>24 files · Updated 2h ago</CardDescription>
        <CardAction>
          <Button aria-label="Open folder" size="icon-sm" variant="ghost">
            <ArrowRightIcon />
          </Button>
        </CardAction>
      </CardHeader>
    </Card>
  );
}
```

### Interactive [#interactive]

```tsx
import { ArrowUpRightIcon } from "lucide-react";
import {
  Card,
  CardAction,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";

export default function Particle() {
  return (
    <Card
      className="w-80"
      render={<button type="button" />}
      ripple
      variant="outlined"
    >
      <CardHeader>
        <CardTitle>Getting Started</CardTitle>
        <CardDescription>
          Install components and configure your theme tokens in minutes.
        </CardDescription>
        <CardAction>
          <ArrowUpRightIcon className="size-4 text-muted-foreground" />
        </CardAction>
      </CardHeader>
    </Card>
  );
}
```

### Card Frame [#card-frame]

```tsx
import { Button } from "@/components/ui/button";
import {
  CardFrame,
  CardFrameAction,
  CardFrameDescription,
  CardFrameFooter,
  CardFrameHeader,
  CardFramePanel,
  CardFrameTitle,
} from "@/components/ui/card";

export default function Particle() {
  return (
    <CardFrame className="w-96">
      <CardFrameHeader>
        <CardFrameTitle>Notifications</CardFrameTitle>
        <CardFrameDescription>
          Choose how you want to be notified.
        </CardFrameDescription>
        <CardFrameAction>
          <Button size="xs" variant="outline">
            Reset
          </Button>
        </CardFrameAction>
      </CardFrameHeader>
      <CardFramePanel>
        <p className="text-muted-foreground text-sm">
          Receive product updates, weekly digests, and security alerts directly
          in your inbox.
        </p>
      </CardFramePanel>
      <CardFrameFooter>
        <span className="text-muted-foreground text-xs">
          Last updated just now
        </span>
        <Button size="xs">Save</Button>
      </CardFrameFooter>
    </CardFrame>
  );
}
```

## API Reference [#api-reference]

### Card [#card]

The root surface container. Supports polymorphic rendering via Base UI `useRender` (such as `<a>` or `<button>` for interactive cards).

| Prop          | Type                                                | Default      | Description                                           |
| ------------- | --------------------------------------------------- | ------------ | ----------------------------------------------------- |
| `variant`     | `"default" \| "elevated" \| "filled" \| "outlined"` | `"default"`  | Surface style variant                                 |
| `orientation` | `"vertical" \| "horizontal"`                        | `"vertical"` | Layout direction of the card                          |
| `ripple`      | `boolean`                                           | `false`      | Enables Material ripple feedback on pointer press     |
| `render`      | `React.ReactElement \| ((props, state) => React.ReactElement)` | - | Custom element to render (e.g. `<Link />` or `<button />`) |
| `className`   | `string`                                            | -            | Additional CSS classes                                |
| `...props`    | `React.ComponentProps<"div">`                       | -            | All standard div attributes are supported             |

### CardHeader [#cardheader]

Grid header container that automatically accommodates a `CardTitle`, `CardDescription`, and an optional `CardAction`.

### CardTitle [#cardtitle]

Displays the heading of the card.

| Prop        | Type            | Default | Description            |
| ----------- | --------------- | ------- | ---------------------- |
| `size`      | `"md" \| "lg"`  | `"md"`  | Title typography scale |
| `className` | `string`        | -       | Additional CSS classes |

### CardDescription [#carddescription]

Secondary muted text positioned beneath `CardTitle`.

### CardAction [#cardaction]

Right-aligned slot inside `CardHeader` for a badge, icon, or action button.

### CardMedia [#cardmedia]

Media wrapper for `<img>` or `<video>` elements, adapting automatically when `orientation="horizontal"`.

### CardPanel / CardContent [#cardpanel--cardcontent]

Main body container of the card. Automatically adjusts vertical padding when paired with `CardHeader` or `CardFooter`.

### CardFooter [#cardfooter]

Horizontal action row at the bottom of the card.

### CardFrame [#cardframe]

Outer muted frame (`rounded-3xl bg-muted p-1.5`) for grouping a `CardFrameHeader`, `CardFramePanel` (or stacked `Card`s), and `CardFrameFooter`.

### CardFrameHeader / CardFrameTitle / CardFrameDescription / CardFrameAction [#cardframeheader--cardframetitle--cardframedescription--cardframeaction]

Header slots rendered directly on the outer `CardFrame` surface.

### CardFramePanel / CardFrameContent [#cardframepanel--cardframecontent]

Inner elevated card surface (`rounded-2xl bg-card p-6`) inside `CardFrame`.

### CardFrameFooter [#cardframefooter]

Bottom row inside `CardFrame` for metadata and actions.
