{
  "schemaVersion": 1,
  "target": "react",
  "name": "table",
  "version": "0.1.0",
  "category": "data",
  "title": "Table",
  "description": "Semantic table parts with hairline rows, right-aligned tabular numbers, a framed option, and a header that can stay pinned while the body scrolls.",
  "tags": [
    "table",
    "data",
    "rows",
    "sticky-header"
  ],
  "requires": {
    "projectTypes": [
      "next",
      "vite-react"
    ],
    "styling": "tailwind-v4"
  },
  "npmDependencies": {},
  "registryDependencies": [],
  "docsPath": "/components/table",
  "props": [
    {
      "name": "Table stickyHeader",
      "type": "boolean",
      "default": "false",
      "description": "Pins the header row while the body scrolls. Give containerClassName a max height to scroll in."
    },
    {
      "name": "Table framed",
      "type": "boolean",
      "default": "false",
      "description": "Draws the container hairline, radius, and surface around the table."
    },
    {
      "name": "Table density",
      "type": "\"default\" | \"compact\"",
      "default": "\"default\"",
      "description": "Row height: 44px or 36px."
    },
    {
      "name": "Table containerClassName",
      "type": "string",
      "description": "Classes for the scrolling wrapper; className styles the <table>."
    },
    {
      "name": "TableHead / TableCell numeric",
      "type": "boolean",
      "default": "false",
      "description": "Right-aligns the cell and uses tabular figures so digits line up."
    },
    {
      "name": "TableHead / TableCell align",
      "type": "\"start\" | \"center\" | \"end\"",
      "description": "Horizontal alignment. numeric implies end."
    },
    {
      "name": "TableRow selected",
      "type": "boolean",
      "default": "false",
      "description": "Applies the selected tint and aria-selected."
    },
    {
      "name": "TableHeader / TableBody / TableFooter / TableCaption",
      "type": "native thead / tbody / tfoot / caption props",
      "description": "Semantic parts; the caption names the table and renders below it."
    }
  ],
  "accessibility": [
    "Renders native table, thead, tbody, tfoot, th, td, and caption elements, so screen readers announce rows, columns, and headers.",
    "TableHead defaults to scope=\"col\".",
    "TableCaption names the table; hide it visually with className=\"sr-only\" when a heading already describes it.",
    "The wrapper scrolls sideways on narrow screens instead of squeezing columns.",
    "Rows separate by hairlines rather than color alone; the hover tint is decorative."
  ],
  "states": [
    "default",
    "hover",
    "selected",
    "sticky header",
    "compact"
  ],
  "files": [
    {
      "path": "ui/table.tsx",
      "content": "import type { ComponentProps } from \"react\";\n\nfunction cx(...classes: (string | false | null | undefined)[]) {\n  return classes.filter(Boolean).join(\" \");\n}\n\nexport interface TableProps extends ComponentProps<\"table\"> {\n  /**\n   * Keeps the header row pinned while the body scrolls. Give the table a height to scroll in,\n   * for example `containerClassName=\"max-h-80\"`.\n   */\n  stickyHeader?: boolean;\n  /** Draws the container hairline, radius, and surface around the table. */\n  framed?: boolean;\n  /** Row height. `compact` suits dense logs and side panels. */\n  density?: \"default\" | \"compact\";\n  /** Classes for the scrolling wrapper. `className` styles the `<table>` itself. */\n  containerClassName?: string;\n}\n\n/**\n * A semantic `<table>` inside a scrolling wrapper. Rows are separated by hairlines, never by\n * zebra fills. The wrapper scrolls sideways on narrow screens instead of squeezing columns.\n */\nexport function Table({\n  stickyHeader = false,\n  framed = false,\n  density = \"default\",\n  containerClassName,\n  className,\n  ...props\n}: TableProps) {\n  return (\n    <div\n      data-slot=\"table-container\"\n      className={cx(\n        \"relative w-full overflow-auto\",\n        framed &&\n          cx(\n            \"rounded-xl border border-zinc-950/10 bg-white shadow-[0_1px_2px_rgb(0_0_0/0.04)]\",\n            \"dark:border-white/10 dark:bg-black dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.06)]\",\n          ),\n        containerClassName,\n      )}\n    >\n      <table\n        data-sticky={stickyHeader || undefined}\n        data-density={density}\n        data-framed={framed || undefined}\n        className={cx(\n          // Separate borders so hairlines stay attached to cells when the header sticks.\n          \"group/table w-full border-separate border-spacing-0 text-left text-sm text-zinc-950 dark:text-white\",\n          className,\n        )}\n        {...props}\n      />\n    </div>\n  );\n}\n\n/** The `<thead>`. Holds one or more rows of `TableHead` cells. */\nexport function TableHeader({ className, ...props }: ComponentProps<\"thead\">) {\n  return <thead className={cx(\"[&>tr]:hover:bg-transparent dark:[&>tr]:hover:bg-transparent\", className)} {...props} />;\n}\n\n/** The `<tbody>`. The last row drops its bottom hairline so it meets the container edge cleanly. */\nexport function TableBody({ className, ...props }: ComponentProps<\"tbody\">) {\n  return (\n    <tbody\n      className={cx(\n        \"group-data-[framed]/table:[&>tr:last-child>*]:border-b-0\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\n/** The `<tfoot>`, for totals. Set off from the body by a stronger hairline. */\nexport function TableFooter({ className, ...props }: ComponentProps<\"tfoot\">) {\n  return (\n    <tfoot\n      className={cx(\n        \"font-medium [&>tr>*]:border-b-0 [&>tr:first-child>*]:border-t [&>tr:first-child>*]:border-zinc-950/10 dark:[&>tr:first-child>*]:border-white/10\",\n        \"[&>tr]:hover:bg-transparent dark:[&>tr]:hover:bg-transparent\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nexport interface TableRowProps extends ComponentProps<\"tr\"> {\n  /** Marks the row as selected: a tint and `aria-selected`. */\n  selected?: boolean;\n}\n\n/** A `<tr>` with a hairline under each cell and a quiet hover tint. */\nexport function TableRow({ selected, className, ...props }: TableRowProps) {\n  return (\n    <tr\n      data-selected={selected || undefined}\n      aria-selected={selected}\n      className={cx(\n        \"[&>*]:border-b [&>*]:border-zinc-950/[0.07] dark:[&>*]:border-white/[0.08]\",\n        \"transition-[background-color] duration-150 ease-out motion-reduce:transition-none\",\n        \"hover:bg-zinc-950/[0.025] dark:hover:bg-white/[0.04]\",\n        \"data-[selected]:bg-zinc-950/[0.045] dark:data-[selected]:bg-white/[0.07]\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\ntype Align = \"start\" | \"center\" | \"end\";\n\nconst alignment: Record<Align, string> = {\n  start: \"text-left\",\n  center: \"text-center\",\n  end: \"text-right\",\n};\n\nexport interface TableCellProps extends Omit<ComponentProps<\"td\">, \"align\"> {\n  /** Right-aligns the cell and uses tabular figures, so digits line up down the column. */\n  numeric?: boolean;\n  /** Horizontal alignment. `numeric` implies `end`. */\n  align?: Align;\n}\n\nexport interface TableHeadProps extends Omit<ComponentProps<\"th\">, \"align\"> {\n  /** Right-aligns the header to sit over a numeric column. */\n  numeric?: boolean;\n  /** Horizontal alignment. `numeric` implies `end`. */\n  align?: Align;\n}\n\n/** A header cell (`<th>`). Sentence case meta text; sticks to the top when the table has `stickyHeader`. */\nexport function TableHead({ numeric = false, align, scope = \"col\", className, ...props }: TableHeadProps) {\n  return (\n    <th\n      scope={scope}\n      className={cx(\n        \"h-9 px-3 align-middle text-xs font-medium whitespace-nowrap text-zinc-500 group-data-[density=compact]/table:h-8\",\n        \"border-b border-zinc-950/10 dark:border-white/10\",\n        \"first:pl-4 last:pr-4\",\n        \"group-data-[sticky]/table:sticky group-data-[sticky]/table:top-0 group-data-[sticky]/table:z-10\",\n        \"group-data-[sticky]/table:bg-white dark:group-data-[sticky]/table:bg-black\",\n        alignment[align ?? (numeric ? \"end\" : \"start\")],\n        numeric && \"tabular-nums\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\n/** A body cell (`<td>`). */\nexport function TableCell({ numeric = false, align, className, ...props }: TableCellProps) {\n  return (\n    <td\n      className={cx(\n        \"h-11 px-3 align-middle group-data-[density=compact]/table:h-9\",\n        \"first:pl-4 last:pr-4\",\n        alignment[align ?? (numeric ? \"end\" : \"start\")],\n        numeric && \"tabular-nums\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\n/** The `<caption>`. Names the table for assistive technology; rendered below it as meta text. */\nexport function TableCaption({ className, ...props }: ComponentProps<\"caption\">) {\n  return <caption className={cx(\"caption-bottom px-4 py-3 text-left text-xs text-zinc-500\", className)} {...props} />;\n}\n"
    }
  ],
  "example": {
    "content": "import { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow } from \"@/components/shaken/ui/table\";\n\nconst invoices = [\n  { id: \"INV-2041\", workspace: \"Acme Docs\", period: \"Oct 2026\", tokens: 18_420_000, runs: 1_284, amount: 412.6 },\n  { id: \"INV-2042\", workspace: \"Support triage\", period: \"Oct 2026\", tokens: 6_905_000, runs: 3_117, amount: 158.2 },\n  { id: \"INV-2043\", workspace: \"Release notes bot\", period: \"Oct 2026\", tokens: 1_210_500, runs: 96, amount: 27.45 },\n  { id: \"INV-2044\", workspace: \"Data pipeline\", period: \"Oct 2026\", tokens: 42_870_000, runs: 512, amount: 961.0 },\n];\n\nconst number = new Intl.NumberFormat(\"en-US\");\nconst money = new Intl.NumberFormat(\"en-US\", { style: \"currency\", currency: \"USD\" });\n\nexport default function TableExample() {\n  const total = invoices.reduce((sum, invoice) => sum + invoice.amount, 0);\n  return (\n    <Table framed containerClassName=\"w-full max-w-2xl\">\n      <TableCaption>Usage invoices for October 2026, by workspace.</TableCaption>\n      <TableHeader>\n        <TableRow>\n          <TableHead>Invoice</TableHead>\n          <TableHead>Workspace</TableHead>\n          <TableHead numeric>Tokens</TableHead>\n          <TableHead numeric>Runs</TableHead>\n          <TableHead numeric>Amount</TableHead>\n        </TableRow>\n      </TableHeader>\n      <TableBody>\n        {invoices.map((invoice) => (\n          <TableRow key={invoice.id}>\n            <TableCell className=\"font-mono text-xs text-zinc-600 dark:text-zinc-400\">{invoice.id}</TableCell>\n            <TableCell className=\"font-medium whitespace-nowrap\">{invoice.workspace}</TableCell>\n            <TableCell numeric className=\"text-zinc-600 dark:text-zinc-400\">\n              {number.format(invoice.tokens)}\n            </TableCell>\n            <TableCell numeric className=\"text-zinc-600 dark:text-zinc-400\">\n              {number.format(invoice.runs)}\n            </TableCell>\n            <TableCell numeric>{money.format(invoice.amount)}</TableCell>\n          </TableRow>\n        ))}\n      </TableBody>\n      <TableFooter>\n        <TableRow>\n          <TableCell colSpan={4}>Total</TableCell>\n          <TableCell numeric>{money.format(total)}</TableCell>\n        </TableRow>\n      </TableFooter>\n    </Table>\n  );\n}\n"
  }
}
