# Table

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

Primitive HTML table building blocks for full layout control. Use the
`Table` family when you need custom cell rendering, row selection, or
complex action columns. For a turnkey table with sorting, filtering, and
pagination see [DataTable](https://refast.fastapicloud.dev/docs/components/data-table).

```python
from refast.components import (
    Table, TableHeader, TableBody,
    TableRow, TableHead, TableCell,
)

Table(
    striped=True,
    children=[
        TableHeader(children=[
            TableRow(children=[
                TableHead(children=["Name"]),
                TableHead(children=["Email"]),
            ])
        ]),
        TableBody(children=[
            TableRow(children=[
                TableCell(children=["Alice"]),
                TableCell(children=["alice@example.com"]),
            ]),
        ]),
    ]
)
```

Name

Email

Role

Alice Johnson

alice@example.com

Admin

Bob Smith

bob@example.com

Editor

Carol White

carol@example.com

Viewer

David Brown

david@example.com

Editor

Eva Green

eva@example.com

Viewer

```python
Table(
    striped=False,
    hoverable=True,
    children=[
        TableHeader(children=[
            TableRow(children=[
                TableHead(children=["Name"]),
                TableHead(children=["Email"]),
                TableHead(children=["Role"]),
            ])
        ]),
        TableBody(children=[
            TableRow(children=[
                TableCell(children=["Alice Johnson"]),
                TableCell(children=["alice@example.com"]),
                TableCell(children=["Admin"]),
            ]),
            # ... more rows
        ]),
    ]
)
```

## Table Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `list` | `[]` | `TableHeader` and `TableBody` components. |
| `striped` | `bool` | `False` | Enables zebra-striping for body rows. |
| `hoverable` | `bool` | `True` | Body rows show a hover highlight. |
| `class_name` | `str` | `""` | Extra Tailwind classes. |

## TableHeader / TableBody Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `list` | `[]` | `TableRow` components. |
| `class_name` | `str` | `""` | Extra Tailwind classes. |

## TableRow Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `list` | `[]` | `TableHead` or `TableCell` components. |
| `class_name` | `str` | `""` | Extra Tailwind classes. |

## TableHead Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `list` | `[]` | Header cell content. |
| `class_name` | `str` | `""` | Extra Tailwind classes (e.g. `"text-right"`). |

## TableCell Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `list` | `[]` | Cell content. |
| `col_span` | `int \| None` | `None` | Number of columns to span. |
| `row_span` | `int \| None` | `None` | Number of rows to span. |
| `class_name` | `str` | `""` | Extra Tailwind classes. |

## Spanning cells

```python
TableRow(children=[
    TableCell(children=["Total"], col_span=2, class_name="font-bold"),
    TableCell(children=["42"], class_name="text-right"),
])
```

## Aligned columns

```python
TableHead(children=["Amount"], class_name="text-right")
TableCell(children=["$99.00"], class_name="text-right font-mono")
```

---

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).
