VisorVisor
ComponentsData Display

Table

Semantic HTML table components for structured data display.

Basic Table

NameEmailRole
Alicealice@example.comAdmin
Bobbob@example.comEditor
Carolcarol@example.comViewer

With Caption

Use TableCaption to add a visible description of the table.

Monthly subscription metrics
PlanSubscribersRevenue
Starter1,240$12,400
Pro830$41,500

Use TableFooter for summary rows such as totals.

ItemQtyPrice
Widget A3$30.00
Widget B2$24.00
Total$54.00

Installation

npx visor add table

This copies two files into your project:

  • components/ui/table/table.tsx — the component
  • components/ui/table/table.module.css — the styles

Usage

import {
  Table, TableHeader, TableBody, TableRow, TableHead, TableCell
} from '@/components/ui/table/table';

export default function Example() {
  return (
    <Table>
      <TableHeader>
        <TableRow>
          <TableHead>Name</TableHead>
          <TableHead>Email</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        <TableRow>
          <TableCell>Alice</TableCell>
          <TableCell>alice@example.com</TableCell>
        </TableRow>
      </TableBody>
    </Table>
  );
}

API Reference

TableProps

PropTypeDefaultDescription
classNamestringAdditional CSS class names for the table element.
scope'col' | 'row''col'Scope attribute for TableHead cells.

Sub-components

ComponentElementPurpose
Table<table>Root table element, wrapped in a scroll container
TableHeader<thead>Header section
TableBody<tbody>Body section
TableFooter<tfoot>Footer section (totals, summaries)
TableRow<tr>Table row
TableHead<th>Header cell, defaults to scope="col"
TableCell<td>Data cell
TableCaption<caption>Visible table description

Accessibility

  • Uses native semantic HTML elements (<table>, <thead>, <tbody>, <th>, <td>) for maximum screen reader compatibility.
  • TableHead renders <th> with scope="col" by default. Pass scope="row" for row headers.
  • Add a TableCaption to give the table a programmatically associated description — this is especially important for data tables.
  • For complex tables, use colSpan and rowSpan props on TableHead / TableCell as needed.
  • The outer scroll container ensures the table remains accessible on small viewports.