# Card

shadcn card as a raised bevelled pixel panel.

Source: https://www.ui95.dev/ui/card

## Examples

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

import type { ShowcaseDemo } from "../types"

function renderCard(size: "default" | "sm") {
  return (
    <Card size={size}>
      <CardHeader>
        <CardTitle>My Computer</CardTitle>
        <CardDescription>3 drives, 1 printer</CardDescription>
      </CardHeader>
      <CardContent>Free space on C: is 12 MB. Consider deleting your memories.</CardContent>
    </Card>
  )
}

export const demo: ShowcaseDemo = {
  span: "single",
  variants: [
    { label: "default", render: () => renderCard("default") },
    { label: "sm", render: () => renderCard("sm") },
    {
      label: "action, footer",
      render: () => (
        <Card>
          <CardHeader className="border-b">
            <CardTitle>Inbox</CardTitle>
            <CardDescription>You have new mail</CardDescription>
            <CardAction>
              <Badge>3</Badge>
            </CardAction>
          </CardHeader>
          <CardContent>Re: Re: Fwd: chain letter</CardContent>
          <CardFooter className="justify-end">
            <Button size="sm" variant="outline">
              Later
            </Button>
            <Button size="sm">Read</Button>
          </CardFooter>
        </Card>
      ),
    },
  ],
}
```

## Installation

```bash
npx shadcn@latest add https://www.ui95.dev/r/card.json
```

Run it in a Radix shadcn project that already has the UI95 theme.

Dependencies:

```bash
npm install cn
```

`components/ui/card.tsx`

```tsx
import { cn } from "cn"
import * as React from "react"

function Card({
  className,
  size = "default",
  ...props
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
  return (
    <div
      data-slot="card"
      data-size={size}
      className={cn(
        "group/card flex flex-col gap-(--card-spacing) overflow-hidden pixel-border border-border bg-card py-(--card-spacing) text-xl leading-tight text-card-foreground bevel-raised offset-shadow-none [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] 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-2 px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:border-b-(length:--pixel) [.border-b]:pb-(--card-spacing)",
        className
      )}
      {...props}
    />
  )
}

function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-title"
      className={cn(
        "font-pixel text-[16px] leading-none uppercase 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-lg leading-tight 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-(length:--pixel) border-border p-(--card-spacing)",
        className
      )}
      {...props}
    />
  )
}

export {
  Card,
  CardAction,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
}
```

## API reference

### Card

| Prop | Type | Default |
| --- | --- | --- |
| `size` | `"sm" \| "default"` | `"default"` |

### CardAction

No props of its own. It forwards the props of the element or primitive it wraps.

### CardContent

No props of its own. It forwards the props of the element or primitive it wraps.

### CardDescription

No props of its own. It forwards the props of the element or primitive it wraps.

### CardFooter

No props of its own. It forwards the props of the element or primitive it wraps.

### CardHeader

No props of its own. It forwards the props of the element or primitive it wraps.

### CardTitle

No props of its own. It forwards the props of the element or primitive it wraps.
