---
description: Styled data tables (`table[table]`) and horizontally scrolling `DataTable`
  frames
output-file: data.html
title: data

---
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

Use `Table(..., table=True)` for a styled table with `caption`, `thead`, `tbody`, and `tfoot`. [`DataTable`](data.md#datatable) wraps that table in a bordered, raised frame (`[table-frame]`). Inside [`DataTable`](data.md#datatable), cells stay on one line and the frame scrolls horizontally when the table is wider than its parent container.

```python
from fasthtml.common import *
from answerui.demo import demo
from fastcore.test import *
```

## Tables

When you pass `table=True` to `Table`, `thead th` and `tfoot th` are semibold (`--weight1`), with horizontal borders under the header and between body and footer rows. Any `caption` appears below the table in muted `--text-1` text. Add `num=True` to a `Th` or `Td` to align it to the end with tabular digits (`font-variant-numeric: tabular-nums`). Inside `[prose]`, the prose stylesheet formats unmarked `table` elements with `.875em` text and prose spacing.

[`DataTable`](data.md#datatable) wraps `Table(*c, table=True)` in a `Div` with `table_frame=True` (`[table-frame]`). That container has a border, a `--raised` shadow, `overflow-x: auto`, and `contain: inline-size`. Because of `contain: inline-size`, a wide table scrolls inside the frame rather than widening the page or its containing card. Inside `[table-frame]`, `thead th` has a `--color-surface` background and cells stay on one line (`white-space: nowrap`). Keyword attributes passed to [`DataTable`](data.md#datatable) apply to the outer `Div`. For keyboard scrolling, pass `role='region'`, `tabindex=0`, and `aria_label` on [`DataTable`](data.md#datatable). Focused frames show the `--ring` outline (`[table-frame]:focus-visible`).

---

### DataTable

```python
def DataTable(
    *c, **attrs
):
```

*A table in a bordered frame that scrolls when its contents are wider than its container*

Here is a quarterly regional summary using `Caption`, `num=True` on numeric cells, and totals in `Tfoot`:

```python
DataTable.demo()
```

## Summary list

[`SummaryList`](data.md#summarylist) renders an opt-in key-value `<dl summary-list>` of `<div><dt>...</dt><dd>...</dd></div>` rows with hairline dividers and an optional trailing action `<dd>`. Each tuple `(key, value)` or `(key, value, action)` becomes one row; pass raw `Div(...)` elements for custom row attributes. Rows stack cleanly in narrow containers (`< 28rem`) via a container query.

---

### SummaryList

```python
def SummaryList(
    *rows, **attrs
):
```

*A hairline-divided key-value `<dl>` with optional trailing action per row*

```python
SummaryList.demo()
```
