Components · Data Display
Data Table
Shows rows of data that people need to compare.
Component Workbench
Switch between the live interactive preview, syntax-highlighted implementation code, copyable AI coding agent prompt, and designer anatomy blueprint.
Data Table · Canonical Spec
| Node | Region | Status | Latency |
|---|---|---|---|
| iad-01 | us-east-1 | Active | 1.24 ms |
| sfo-04 | us-west-2 | Active | 2.89 ms |
| fra-09 | eu-central-1 | Degraded | 14.10 ms |
| gru-05 | sa-east-1 | Offline | 38.70 ms |
| lhr-02 | eu-west-2 | Active | 3.07 ms |
<div class="as-table-container">
<div class="as-table-scroll">
<table class="as-table as-table--interactive">
<caption class="as-sr-only">Active Deployments</caption>
<thead>
<tr>
<th scope="col" class="as-table__th">Service</th>
<th scope="col" class="as-table__th">Region</th>
<th scope="col" class="as-table__th as-table__th--num">Latency</th>
</tr>
</thead>
<tbody>
<tr class="as-table__row">
<th scope="row" class="as-table__cell as-table__cell--primary">api-gateway</th>
<td class="as-table__cell">us-east-1</td>
<td class="as-table__cell as-table__cell--num">1.24 ms</td>
</tr>
</tbody>
</table>
</div>
</div> # Aster Component Implementation Prompt — Data Table
## 1. Component Purpose & Canonical Role
- **Component:** Data Table (`table`)
- **Category:** Data Display
- **Native Element:** `<table>`
- **Summary:** Shows rows of data that people need to compare.
- **When to Use:** Datasets with comparable attributes such as server nodes, logs, and transactions.
- **When Not to Use:** Simple single-column lists or page layout grids.
## 2. Authoritative Repository Files
- **Component CSS:** `components/table/table.css`
- **Component Spec:** `docs/components/table.md`
- **Agent Contract:** `skills/using-aster-components/SKILL.md`
- **Compiled Bundle:** `dist/css/aster.css` and `dist/js/aster.js`
## 3. Canonical HTML Structure & Classes
```html
<div class="as-table-container">
<div class="as-table-scroll">
<table class="as-table as-table--interactive">
<caption class="as-sr-only">Active Deployments</caption>
<thead>
<tr>
<th scope="col" class="as-table__th">Service</th>
<th scope="col" class="as-table__th">Region</th>
<th scope="col" class="as-table__th as-table__th--num">Latency</th>
</tr>
</thead>
<tbody>
<tr class="as-table__row">
<th scope="row" class="as-table__cell as-table__cell--primary">api-gateway</th>
<td class="as-table__cell">us-east-1</td>
<td class="as-table__cell as-table__cell--num">1.24 ms</td>
</tr>
</tbody>
</table>
</div>
</div>
```
## 4. Measured Geometry
Measured from the rendered component when this page loads.
## 5. Non-Negotiable Aster Constraints
1. **Zero Primitive Color Leaks:** Bind colors strictly to `--as-semantic-color-*` custom properties. Never use `--as-color-primitive-*` or hardcoded hex values in component usage.
2. **Minimum 4px Radius Policy:** Never use `2px` border-radius. Use `--as-radius-sm` (`4px`), `--as-radius-md` (`8px`), `--as-radius-lg` (`12px`), or `--as-radius-full` (`9999px`).
3. **Single Standard Density Mode:** Compact mode (`data-density="compact"` / `.as-*--compact`) is permanently retired. Do not emit compact classes or attributes.
4. **WCAG 2.2 AA Accessibility:** Maintain >= 4.5:1 text contrast, >= 3:1 UI/border contrast, >= 24x24px interactive hit targets, and full keyboard operability (`Tab`, `Enter`, `Space`, `Escape`, Arrow keys).
## 6. Verification Commands
```bash
npm run test:components
npm run test:contrast
npm run test:browser
``` When to use it
Do
- Right-align numbers so digits line up.
- Give the table a caption, even if it's visually hidden.
Don't
- Use it for page layout.
- Squeeze in columns nobody compares.
Variants & States
Every option, rendered live with real styles.
Accessibility & Keyboard Interaction
Requirements for using this component accessibly, following the W3C ARIA Authoring Practices Guide.
| Interaction / Key | Behavior & Compliance Requirement |
|---|---|
| Caption & Scopes | Includes <caption>, scope="col", and scope="row". |
| Sort Cycling | Updates aria-sort="ascending|descending|none" on header cells. |
| Overflow Region | Scroll container receives tabindex="0" and role="region" when overflowing. |
Tokens
Values update with the current theme.
| Role | Token | Current value |
|---|---|---|
| Row Height | --as-density-table-row-height | |
| Header Surface | --as-semantic-color-surface-subtle | |
| Row Divider | --as-semantic-color-border-subtle |