# Table

Responsive native tables with readable density. (CSS only.)

Reference: https://timeless.build/docs/components/table/

## Markup

```html
<div class="ui-table" role="region" aria-label="Primitive coverage table" tabindex="0">
  <table>
    <caption>
      <span data-ui-part="caption">Primitive coverage</span>
      <span data-ui-part="description">CSS-only component contracts in this milestone batch.</span>
    </caption>
    <thead>
      <tr>
        <th scope="col">Primitive</th>
        <th scope="col">Contract</th>
        <th scope="col" data-ui-align="end">Depth</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row">Badge</th>
        <td><code class="ui-code">.ui-badge</code></td>
        <td data-ui-align="end">Flat</td>
      </tr>
      <tr>
        <th scope="row">Card</th>
        <td><code class="ui-code">.ui-card</code></td>
        <td data-ui-align="end">Flat</td>
      </tr>
    </tbody>
  </table>
</div>
```

## Install

```js
import '@timelessui/components/css/tokens.css'
import '@timelessui/components/css/core/table.css'
import '@timelessui/components/css/core/badge.css'
import '@timelessui/components/css/themes/atmosphere/tokens.css'
import '@timelessui/components/css/themes/atmosphere/badge.css'
import '@timelessui/components/css/themes/atmosphere/table.css'
```

## Anatomy

Parts are authored in your own markup and identified by the selector below. Required parts
must be present for the component to work. Private `data-ui-internal-*` hooks are written by
the runtime and must never be authored.

| Part | Required | Selector | Purpose |
| --- | --- | --- | --- |
| `caption` | No | `[data-ui-part~='caption']` | Table name. Use `<caption>`. |
| `description` | No | `[data-ui-part~='description']` | Supporting copy inside the caption. |
| `empty` | No | `[data-ui-part~='empty']` | Row shown in place of data when the table has none. |

## Attributes

Every value below is implemented by the stylesheets this component ships. Boolean attributes
are presence-based: author the attribute with no value, or omit it.

| Attribute | Values | Default | Description |
| --- | --- | --- | --- |
| `data-ui-density` | `compact` · `normal` | `normal` | Cell padding. |
| `data-ui-align` | `start` · `end` | `start` | Cell text alignment. Set it on a `<th>` or `<td>`, not on the table. `end` also enables tabular numerals. |

## Styling

Root identity: `ui-table`.
Required stylesheets: `tokens.css`, `core/table.css`, `core/badge.css`, `themes/atmosphere/tokens.css`, `themes/atmosphere/badge.css`, `themes/atmosphere/table.css`.

This component adds no custom properties of its own. Restyle it through the design tokens at https://timeless.build/docs/styling/theming/ or your own CSS.

Design tokens this component reads (21), global and set at the theme level: `--ui-accent-soft`, `--ui-bg-control-muted`, `--ui-bg-surface`, `--ui-bg-surface-raised`, `--ui-danger`, `--ui-danger-soft`, `--ui-fg`, `--ui-fg-muted`, `--ui-focus`, `--ui-line`, `--ui-radius-lg`, `--ui-radius-pill`, `--ui-space-1`, `--ui-space-2`, `--ui-space-3`, `--ui-space-4`, `--ui-space-5`, `--ui-success`, `--ui-success-soft`, `--ui-warning`, `--ui-warning-soft`.

## Accessibility

Keep the native elements, roles, and relationships shown in the markup. Timeless adds only the
state and keyboard coordination the platform does not already provide, and it never supplies
your accessible names — those depend on your content.

This component declares no keyboard contract, because it has none of its own: the markup above
is native elements and native ARIA, and everything a keyboard or a screen reader does with it
comes from the platform. Nothing here manages focus, and nothing here adds a role you did not
author. So the accessibility of this component is the accessibility of the markup — which is why
the markup is the part worth copying exactly.

## Before JavaScript runs

This primitive is CSS only. There is nothing to register and nothing to wait for.
