# Card: Clickable card

> Put a `<CardLink />` in the title to make the whole card one link. Buttons and other controls inside stay clickable and keep their own focus, like the star here.

Example: https://hextaui.com/docs/card/examples/link
Component docs: https://hextaui.com/docs/card.md

## Add this example

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

This adds `components/examples/card/link.tsx` with the Card component and the HextaUI theme tokens.

## Source

```tsx title="components/examples/card/link.tsx"
"use client"

import * as React from "react"
import { IconGitBranch, IconStar } from "@tabler/icons-react"

import { Button } from "@/components/ui/button"
import {
  Card,
  CardAction,
  CardDescription,
  CardFooter,
  CardHeader,
  CardLink,
  CardTitle,
} from "@/components/ui/card"

const projects = [
  {
    name: "Acme website",
    description: "Marketing site and docs, deployed on every push.",
    stars: 128,
    branch: "main",
  },
  {
    name: "Payments service",
    description: "Card processing, webhooks and the reconciliation job.",
    stars: 42,
    branch: "release/2.4",
  },
]

export function CardClickable() {
  const [starred, setStarred] = React.useState<string[]>([])

  return (
    <div className="grid w-full gap-4 sm:grid-cols-2">
      {projects.map((project) => {
        const isStarred = starred.includes(project.name)

        return (
          <Card key={project.name}>
            <CardHeader>
              <CardTitle>
                <CardLink href="#">{project.name}</CardLink>
              </CardTitle>
              <CardDescription>{project.description}</CardDescription>
              <CardAction>
                <Button
                  variant="ghost"
                  size="icon-sm"
                  aria-label={`Star ${project.name}`}
                  aria-pressed={isStarred}
                  onClick={() =>
                    setStarred(
                      isStarred
                        ? starred.filter((name) => name !== project.name)
                        : [...starred, project.name]
                    )
                  }
                >
                  <IconStar className={isStarred ? "fill-current" : ""} />
                </Button>
              </CardAction>
            </CardHeader>
            <CardFooter>
              <span className="flex items-center gap-1 text-muted-foreground">
                <IconGitBranch className="size-4" />
                {project.branch}
              </span>
              <span className="ms-auto text-muted-foreground">
                {project.stars + (isStarred ? 1 : 0)} stars
              </span>
            </CardFooter>
          </Card>
        )
      })}
    </div>
  )
}
```

## Props in this example

### CardLink

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `href` | `string` | – |  |

## More Card examples

- [Variants](https://hextaui.com/docs/card/examples/variants.md)
- [Sizes](https://hextaui.com/docs/card/examples/sizes.md)
- [Media](https://hextaui.com/docs/card/examples/media.md)
- [Clickable variants](https://hextaui.com/docs/card/examples/link-variants.md)
- [Borders](https://hextaui.com/docs/card/examples/borders.md)
- [Nested](https://hextaui.com/docs/card/examples/nested.md)
- [Long content](https://hextaui.com/docs/card/examples/long-content.md)
- [Semantics](https://hextaui.com/docs/card/examples/semantics.md)
- [Right to left](https://hextaui.com/docs/card/examples/rtl.md)
