# Table

A plain table in a labeled area you can scroll with the keyboard.

- **Use it for**: Read-only tabular data with native semantics.
- **Not for**: Sorting, paging and selection. Try [DataGrid](https://unseenui.com/components/data-grid/).

## Installation

```bash
npm install @stackunseen/ui
```

## Parts

A native HTML table with the library styles. Wide tables scroll sideways in their own keyboard-reachable area.

```tsx
<Table label="Packages">
  <Table.Caption>Sample package status</Table.Caption>
  <Table.Header>
    <Table.Row>
      <Table.Head>Package</Table.Head>
      <Table.Head>Status</Table.Head>
    </Table.Row>
  </Table.Header>
  <Table.Body>
    <Table.Row>
      <Table.Head scope="row">Components</Table.Head>
      <Table.Cell>Experimental alpha</Table.Cell>
    </Table.Row>
  </Table.Body>
</Table>
```

1. **`Table`**: `label` names the table, even without a caption. Props: `label`, `scrollLabel`.
2. **`Table.Caption`**: An optional visible title.
3. **`Table.Header`**: Group the rows. `Table.Body` and `Table.Footer` work the same way.
4. **`Table.Row`**: One row.
5. **`Table.Head`**: A header cell. Use `scope="row"` for a heading at the start of a row.
6. **`Table.Cell`**: A data cell.

## Usage

```tsx
import { Table } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<Table label="Packages"><Table.Caption>Sample package status</Table.Caption><Table.Header><Table.Row><Table.Head>Package</Table.Head><Table.Head>Status</Table.Head></Table.Row></Table.Header><Table.Body><Table.Row><Table.Head scope="row">Components</Table.Head><Table.Cell>Experimental alpha</Table.Cell></Table.Row></Table.Body></Table>
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `label` (required) | `string` | Names the table independently of its optional visible caption. |
| `scrollLabel` | `string` | Names the keyboard-scrollable container. |

## Keyboard

Tab reaches the scroll region when needed; arrow keys scroll wide content. Column and row headers preserve native table semantics.

## Works with

[DataGrid](https://unseenui.com/components/data-grid/), [Pagination](https://unseenui.com/components/pagination/), [Matrix](https://unseenui.com/components/matrix/), [StatusBadge](https://unseenui.com/components/status-badge/), [Card](https://unseenui.com/components/card/), [Tag](https://unseenui.com/components/tag/), [DiffStat](https://unseenui.com/components/diff-stat/), [ElapsedTime](https://unseenui.com/components/elapsed-time/), [Numeric](https://unseenui.com/components/numeric/), [Kbd](https://unseenui.com/components/kbd/), [DotRing](https://unseenui.com/components/dot-ring/), [DotBars](https://unseenui.com/components/dot-bars/)

Page: https://unseenui.com/components/table/
