# Card

- **Section:** Components
- **URL:** https://refast.fastapicloud.dev/docs/components/card
- **Markdown:** https://refast.fastapicloud.dev/docs/components/card.md
- **Source:** https://github.com/idling-mind/refast-docs/blob/main/docs/pages/components/cards/card.py
- **Live examples:** the widgets on this page need a browser; open the URL above to try them.
- **Applies to:** refast 0.12.2

A rounded, bordered container with a subtle drop shadow for grouping related
content and actions into a visually distinct surface.

```python
from refast.components import (
    Card, CardHeader, CardTitle, CardDescription,
    CardContent, CardFooter,
)

Card(
    children=[
        CardHeader(title="Team Members", description="Manage your team."),
        CardContent(children=[Text("Alice — Admin")]),
        CardFooter(children=[Button("Invite Member")]),
    ]
)
```

### Team Members

Manage your team and their access levels.

Alice — Admin

Bob — Editor

Carol — Viewer

```python
Card(
    children=[
        CardHeader(
            children=[
                CardTitle(children=["Team Members"]),
                CardDescription(children=["Manage your team and their access levels."]),
            ]
        ),
        CardContent(children=[...]),
        CardFooter(children=[Button("Cancel"), Button("Save")]),
    ]
)
```

## Card Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `list` | `[]` | Sub-components (`CardHeader`, `CardContent`, `CardFooter`). |
| `title` | `str \| None` | `None` | Shorthand title (rendered without `CardHeader`). |
| `description` | `str \| None` | `None` | Shorthand description below `title`. |
| `on_click` | `Callback \| None` | `None` | Makes the card interactive. |
| `class_name` | `str` | `""` | Extra Tailwind classes. |
| `style` | `dict \| None` | `None` | Inline CSS style dict. |

## CardHeader Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `title` | `str \| None` | `None` | Shorthand heading text. |
| `description` | `str \| None` | `None` | Shorthand subtitle text. |
| `children` | `list` | `[]` | Explicit `CardTitle` / `CardDescription` children. |
| `class_name` | `str` | `""` | Extra Tailwind classes. |

## CardTitle Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `list` | `[]` | Title text. Renders as `<h3>`. |
| `class_name` | `str` | `""` | Extra Tailwind classes. |

## CardDescription Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `list` | `[]` | Description text. Renders as muted `<p>`. |
| `class_name` | `str` | `""` | Extra Tailwind classes. |

## CardContent Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `list` | `[]` | Main body content. |
| `class_name` | `str` | `""` | Extra Tailwind classes. |

## CardFooter Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `list` | `[]` | Footer content — typically action buttons. |
| `class_name` | `str` | `""` | Extra Tailwind classes. |

## Examples

### Shorthand title/description

```python
Card(title="Quick Stats", description="Last 30 days")
```

### Full composition

```python
Card(
    children=[
        CardHeader(
            children=[
                CardTitle("Dashboard"),
                CardDescription("Overview of your metrics"),
            ]
        ),
        CardContent(children=[Text("Your content here.")]),
        CardFooter(
            children=[
                Button("Cancel", variant="outline"),
                Button("Save changes"),
            ]
        ),
    ]
)
```

### Clickable card

```python
async def handle_card_click(ctx: Context):
    await ctx.show_toast("Card clicked!")

Card(
    title="Click me",
    description="This card is interactive.",
    on_click=ctx.callback(handle_card_click),
)
```

---

Part of the Refast documentation: [all pages](https://refast.fastapicloud.dev/llms.txt), [everything on one page](https://refast.fastapicloud.dev/llms-full.txt), [search](https://refast.fastapicloud.dev/api/search?q=save_prop).
