Timace

Table

InvoiceStatusAmount
INV-0042Paid$240.00
INV-0041Due$1,120.00
INV-0040Paid$86.50
components/ui/table.tsx
import type { ComponentProps } from "react";

const join = (...classes: (string | undefined)[]) => classes.filter(Boolean).join(" ");

/** The frame around a table. It scrolls sideways when the table is wider than its place. */
export function Table({ className, children, ...props }: ComponentProps<"table">) {
  return (
    <div data-slot="table" className={join("w-full overflow-x-auto rounded-(--tui-table-radius) border-solid border-(length:--tui-table-border-width) border-(--tui-table-border) bg-(--tui-table-bg)", className)}>
      <table {...props} className="w-full border-collapse font-(family-name:--tui-font) text-(length:--tui-table-font-size) text-(--tui-table-fg)">
        {children}
      </table>
    </div>
  );
}

export function TableHead({ className, ...props }: ComponentProps<"thead">) {
  return <thead {...props} className={join("bg-(--tui-table-head-bg)", className)} />;
}

export function TableBody(props: ComponentProps<"tbody">) {
  return <tbody {...props} />;
}

export function TableRow({ className, ...props }: ComponentProps<"tr">) {
  return <tr {...props} className={join("border-solid border-(--tui-table-border) not-last:border-b-(length:--tui-table-border-width) [tbody>&]:hover:bg-(--tui-table-row-hover)", className)} />;
}

export function TableHeader({ className, ...props }: ComponentProps<"th">) {
  return (
    <th
      scope="col"
      {...props}
      className={join("border-solid border-(--tui-table-border) border-b-(length:--tui-table-border-width) px-(--tui-table-padding-x) py-(--tui-table-padding-y) text-left text-(length:--tui-table-head-size) font-(--tui-table-head-weight) whitespace-nowrap text-(--tui-table-head-fg)", className)}
    />
  );
}

export function TableCell({ className, ...props }: ComponentProps<"td">) {
  return <td {...props} className={join("px-(--tui-table-padding-x) py-(--tui-table-padding-y) align-middle", className)} />;
}
styles/timace-ui.css
:root {
  color-scheme: light;
  --tui-bg: #ffffff;
  --tui-fg: #0a0a0a;
  --tui-muted: #f5f5f5;
  --tui-muted-fg: #737373;
  --tui-border: #e5e5e5;
  --tui-primary: #171717;
  --tui-primary-fg: #fafafa;
  --tui-ring: #a3a3a3;
  --tui-success: #16a34a;
  --tui-warning: #d97706;
  --tui-danger: #dc2626;
  --tui-radius: 8px;
  --tui-border-width: 1px;
  --tui-space: 4px;
  --tui-shadow: none;
  --tui-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --tui-text: 14px;
  --tui-duration: 150ms;

  /* Table */
  --tui-table-padding-x: calc(var(--tui-space) * 4);
  --tui-table-padding-y: calc(var(--tui-space) * 3);
  --tui-table-radius: var(--tui-radius);
  --tui-table-border-width: var(--tui-border-width);
  --tui-table-font-size: var(--tui-text);
  --tui-table-head-size: 12px;
  --tui-table-head-weight: 500;
  --tui-table-bg: var(--tui-bg);
  --tui-table-fg: var(--tui-fg);
  --tui-table-border: var(--tui-border);
  --tui-table-head-bg: var(--tui-muted);
  --tui-table-head-fg: var(--tui-muted-fg);
  --tui-table-row-hover: color-mix(in oklab, var(--tui-muted) 55%, var(--tui-bg));
}

.dark,
[data-theme="dark"] {
  color-scheme: dark;
  --tui-bg: #0a0a0a;
  --tui-fg: #fafafa;
  --tui-muted: #1c1c1c;
  --tui-muted-fg: #a3a3a3;
  --tui-border: #2a2a2a;
  --tui-primary: #fafafa;
  --tui-primary-fg: #171717;
  --tui-ring: #737373;
  --tui-success: #22c55e;
  --tui-warning: #f59e0b;
  --tui-danger: #ef4444;
}

Needs Tailwind CSS v4. Import the stylesheet once, after Tailwind.