Components
Data Display
Table

Table

Use Table to build consistent, accessible interfaces aligned with the shared design system.

Installation

1. Copy the source code:

  • Source in this monorepo: packages/ui/src/components/table.tsx
  • Place in your project: components/ui/table.tsx
  • Required utility: lib/utils.ts (for cn helper)

2. Update the import paths to match your project structure.


Usage

import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@hoag/ui/components/table";
 
export default function Demo() {
  return (
    <Table>
      <TableHeader>
        <TableRow>
          <TableHead>Plan</TableHead>
          <TableHead>Users</TableHead>
          <TableHead className="text-right">Price</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        <TableRow>
          <TableCell>Starter</TableCell>
          <TableCell>Up to 3</TableCell>
          <TableCell className="text-right">$19</TableCell>
        </TableRow>
        <TableRow>
          <TableCell>Pro</TableCell>
          <TableCell>Up to 10</TableCell>
          <TableCell className="text-right">$49</TableCell>
        </TableRow>
      </TableBody>
    </Table>
  );
}

Import

import {
  Table,
  TableBody,
  TableCaption,
  TableCell,
  TableFooter,
  TableHead,
  TableHeader,
  TableRow,
} from "@hoag/ui/components/table";

Basic Example

PlanUsersPrice
StarterUp to 3$19
ProUp to 10$49
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@hoag/ui/components/table";
 
export function TableBasicExample() {
  return (
    <Table>
      <TableHeader>
        <TableRow>
          <TableHead>Plan</TableHead>
          <TableHead>Users</TableHead>
          <TableHead className="text-right">Price</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        <TableRow>
          <TableCell>Starter</TableCell>
          <TableCell>Up to 3</TableCell>
          <TableCell className="text-right">$19</TableCell>
        </TableRow>
        <TableRow>
          <TableCell>Pro</TableCell>
          <TableCell>Up to 10</TableCell>
          <TableCell className="text-right">$49</TableCell>
        </TableRow>
      </TableBody>
    </Table>
  );
}

Composition Pattern

import { Table } from "@hoag/ui/components/table";
 
export function TableSection() {
  return (
    <section className="space-y-3">
      <h3 className="text-sm font-medium">Table section</h3>
      <Table />
    </section>
  );
}

Accessibility Checklist

  • Verify semantic roles and ARIA attributes for interactive behavior.
  • Keep keyboard navigation and focus visibility consistent in all states.
  • Ensure color contrast meets accessibility requirements in light and dark themes.
  • Provide screen reader context for dynamic state or content changes.

Testing Checklist

  • Add render tests for default and key variant states.
  • Add interaction tests for callbacks and state transitions.
  • Add visual regression checks for responsive and theme variations.
  • Cover edge states such as loading, empty, disabled, and error.

Production Tips

  • Wrap component logic in feature-level abstractions for domain behavior.
  • Keep visual variants centralized to avoid style drift across screens.
  • Reuse a single import path strategy for simpler refactors.
  • Mirror documented states in Storybook and QA checklists.

Named Exports

  • Table
  • TableBody
  • TableCaption
  • TableCell
  • TableFooter
  • TableHead
  • TableHeader
  • TableRow

API Reference

For authoritative prop signatures and implementation details, inspect:

  • packages/ui/src/components/table.tsx

MIT 2026 © @hoag/ui