import { Badge, Table } from "@replicas/ui";

const rows = [
  { id: "INV-1042", description: "Pro plan, monthly", status: "Paid", variant: "success" },
  { id: "INV-1041", description: "Extra seats", status: "Pending", variant: "warning" },
  { id: "INV-1040", description: "Pro plan, monthly", status: "Refunded", variant: "default" },
];

export default function TableDemo() {
  return (
    <Table.Root style={{ width: "100%" }}>
      <Table.Header>
        <Table.Row>
          <Table.Head>Invoice</Table.Head>
          <Table.Head>Description</Table.Head>
          <Table.Head>Status</Table.Head>
        </Table.Row>
      </Table.Header>
      <Table.Body>
        {rows.map((row) => (
          <Table.Row key={row.id}>
            <Table.Cell>{row.id}</Table.Cell>
            <Table.Cell>{row.description}</Table.Cell>
            <Table.Cell>
              <Badge variant={row.variant}>{row.status}</Badge>
            </Table.Cell>
          </Table.Row>
        ))}
      </Table.Body>
    </Table.Root>
  );
}

Prompt

Copy Prompt hands your agent everything it needs to build the Table in the Codex style: the measured tokens, the CSS and the structure.

Show Prompt
# Codex Table

Rows and columns of data.

Build a Table in this project that looks and behaves like Codex's. Measured from the running Codex app (openai.com/codex). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or Base UI primitives if it has none.

Fidelity: Derived from the Codex app's diff file rows and tokens.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--border-primary` | `rgb(13 13 13 / 0.053)` | `rgb(255 255 255 / 0.042)` |
| `--border-secondary` | `rgb(13 13 13 / 0.087)` | `rgb(255 255 255 / 0.084)` |
| `--text-primary` | `rgb(26 28 31)` | `#ffffff` |
| `--text-secondary` | `rgb(21 28 42 / 0.8)` | `rgb(255 255 255 / 0.65)` |
| `--text-tertiary` | `rgb(21 28 42 / 0.494)` | `rgb(255 255 255 / 0.498)` |
| `--bg-hover` | `rgb(13 13 13 / 0.06)` | `rgb(255 255 255 / 0.078)` |
| `--font-size-mini` | `12px` | `12px` |
| `--font-size-small` | `13px` | `13px` |
| `--font-weight-normal` | `430` | `430` |
| `--font-weight-medium` | `500` | `500` |
| `--ease-basic` | `ease` | `ease` |
| `--transition-duration-basic` | `0.15s` | `0.15s` |

## CSS

Scoped under `[data-style="codex"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.

```css
[data-style="codex"] {
  .ui-table-container {
    width: 100%;
    overflow-x: auto;
  }

  .ui-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-normal);
    line-height: 18px;
  }

  .ui-table-caption {
    caption-side: bottom;
    padding-top: 8px;
    color: var(--text-tertiary);
    font-size: var(--font-size-mini);
    line-height: 18px;
    text-align: left;
  }

  .ui-table-head {
    height: 40px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border-secondary);
    color: var(--text-secondary);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-medium);
    text-align: left;
    white-space: nowrap;
  }

  .ui-table-row {
    transition: background-color var(--transition-duration-basic) var(--ease-basic);
  }

  .ui-table-body .ui-table-row {
    @media (hover: hover) {
      &:hover {
        background-color: var(--bg-hover);
      }
    }
  }

  .ui-table-cell {
    height: 48px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border-primary);
    color: var(--text-secondary);
    vertical-align: middle;

    &:first-child {
      color: var(--text-primary);
      font-weight: var(--font-weight-medium);
    }
  }

  .ui-table-body .ui-table-row:last-child .ui-table-cell {
    border-bottom: 0;
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import type { ComponentProps } from "react";
import { join } from "./utils";

function Root({ className, variant, ...props }: ComponentProps<"table"> & { variant?: string }) {
  return (
    <div className="ui-table-container" data-variant={variant}>
      <table className={join("ui-table", className)} data-variant={variant} {...props} />
    </div>
  );
}

function Header({ className, ...props }: ComponentProps<"thead">) {
  return <thead className={join("ui-table-header", className)} {...props} />;
}

function Body({ className, ...props }: ComponentProps<"tbody">) {
  return <tbody className={join("ui-table-body", className)} {...props} />;
}

function Row({ className, ...props }: ComponentProps<"tr">) {
  return <tr className={join("ui-table-row", className)} {...props} />;
}

function Head({ className, ...props }: ComponentProps<"th">) {
  return <th className={join("ui-table-head", className)} {...props} />;
}

function Cell({ className, ...props }: ComponentProps<"td">) {
  return <td className={join("ui-table-cell", className)} {...props} />;
}

function Caption({ className, ...props }: ComponentProps<"caption">) {
  return <caption className={join("ui-table-caption", className)} {...props} />;
}

export const Table = { Root, Header, Body, Row, Head, Cell, Caption };
```

## Example

```tsx
import { Badge, Table } from "@replicas/ui";

const rows = [
  { id: "INV-1042", description: "Pro plan, monthly", status: "Paid", variant: "success" },
  { id: "INV-1041", description: "Extra seats", status: "Pending", variant: "warning" },
  { id: "INV-1040", description: "Pro plan, monthly", status: "Refunded", variant: "default" },
];

export default function TableDemo() {
  return (
    <Table.Root style={{ width: "100%" }}>
      <Table.Header>
        <Table.Row>
          <Table.Head>Invoice</Table.Head>
          <Table.Head>Description</Table.Head>
          <Table.Head>Status</Table.Head>
        </Table.Row>
      </Table.Header>
      <Table.Body>
        {rows.map((row) => (
          <Table.Row key={row.id}>
            <Table.Cell>{row.id}</Table.Cell>
            <Table.Cell>{row.description}</Table.Cell>
            <Table.Cell>
              <Badge variant={row.variant}>{row.status}</Badge>
            </Table.Cell>
          </Table.Row>
        ))}
      </Table.Body>
    </Table.Root>
  );
}
```

## Foundations

The rest of the Codex style, as a skill: https://replicas.raphaelsalaja.com/skills/codex/SKILL.md