# Table (Andromeda Legacy)

Table is a component of the free, MIT-licensed Andromeda Legacy design system from AI Canvas (https://aicanvas.me). Index of every system, component and install setup: https://aicanvas.me/llms.txt

Compound data-table primitive: Table / TableHead / TableBody / TableRow / TableHeader / TableCell. Sortable column headers, row hover highlight, selected-row accent edge. Render TableStyles once on the page to enable the hover styling. On narrow screens, it scrolls sideways; use DataTable for phone layouts.

- Design system: [Andromeda Legacy](https://aicanvas.me/design-systems/andromeda.md)
- License: MIT
- Install slug: `andromeda-table`
- Page: https://aicanvas.me/design-systems/andromeda/table

## Install

```bash
npx shadcn@latest add @aicanvas/andromeda-table
```

Needs a free AI Canvas account; signed out, the command writes a placeholder (an `AccountRequired` notice) instead.

Every Andromeda Legacy component at once: `npx shadcn@latest add @aicanvas/andromeda`.

Token setup: the Install section of https://aicanvas.me/llms.txt.

## Use it

It installs to `components/aicanvas/andromeda/components/Table.tsx` (under `src/` if your project has one). With the usual `@/` alias:

```tsx
import { Table } from '@/components/aicanvas/andromeda/components/Table'
```

## Example

```tsx
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, TableStyles } from '@/components/aicanvas/andromeda/components/Table'

<>
  <TableStyles />
  <Table>
    <TableHead><TableRow hoverable={false}>
        <TableHeader>Invoice</TableHeader>
        <TableHeader align="right">Total</TableHeader>
      </TableRow>
    </TableHead>
    <TableBody>
      <TableRow>
        <TableCell>INV-2048</TableCell>
        <TableCell align="right">$240.00</TableCell>
      </TableRow>
    </TableBody>
  </Table>
</>
```

## Parts

Table is built from `TableRow`, `TableHeader` and `TableCell`. Each part has its own props table below.

## Variants

- `sort` on `TableHeader`: asc, desc or sortable
- `align` on `TableHeader`: left, right or center (default 'left')
- `align` on `TableCell`: left, right or center (default 'left')

## Props

### TableRow

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `selected?` | `boolean` | `false` | Applies surface.active bg + accent-300 left edge. |
| `hoverable?` | `boolean` |  | Adds the hover-lift class (default on only when the row has onClick). |

### TableHeader

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `sort?` | `'asc'\|'desc'\|'sortable'\|undefined` |  | Column sort state; picks the matching caret and sets aria-sort. |
| `align?` | `'left'\|'right'\|'center'` | `'left'` | Horizontal text alignment of the header cell. |

### TableCell

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `align?` | `'left'\|'right'\|'center'` | `'left'` | Horizontal text alignment of the cell content. |
| `muted?` | `boolean` | `false` | Uses text.secondary instead of text.primary. |
| `nowrap?` | `boolean` | `true` | Keeps the cell content on a single line when true. |

## More Andromeda Legacy components

- [Tooltip](https://aicanvas.me/design-systems/andromeda/tooltip.md)
- [Trend Chart](https://aicanvas.me/design-systems/andromeda/trend-chart.md)
- [User Card](https://aicanvas.me/design-systems/andromeda/user-card.md)
- [User Menu](https://aicanvas.me/design-systems/andromeda/user-menu.md)
- [Alert](https://aicanvas.me/design-systems/andromeda/alert.md)
