✦ Asteria UI
Components

Table

A structured data display component with rows and columns, supporting headers, body cells, and optional sorting or selection states.

NameEmailRoleStatus
Alex Johnsonalex@example.comAdminActive
Sam Williamssam@example.comEditorActive
Jamie Brownjamie@example.comViewerInactive

Installation

npx asteria-ui add table

Usage

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

<Table aria-label="Users">
  <TableHeader>
    <TableRow>
      <TableHead>Name</TableHead>
      <TableHead>Status</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell>Alex Johnson</TableCell>
      <TableCell>Active</TableCell>
    </TableRow>
  </TableBody>
</Table>

Examples

Striped

NameEmailRoleStatus
Alex Johnsonalex@example.comAdminActive
Sam Williamssam@example.comEditorActive
Jamie Brownjamie@example.comViewerInactive

Bordered

NameEmailRoleStatus
Alex Johnsonalex@example.comAdminActive
Sam Williamssam@example.comEditorActive
Jamie Brownjamie@example.comViewerInactive

API reference

PropTypeDefaultDescription
variant"default" | "striped" | "bordered""default"Row alternation and outer border/rounded treatment.

Accessibility

Accessibility

  • Native semantics. Renders a real <table>, not div-based markup — every cell, row, and header is natively understood by assistive tech without any extra ARIA.

  • Headers. TableHead renders <th scope="col">, linking each header to its column.

  • Sortable columns (when you add sorting yourself) should set aria-sort on the relevant TableHead.

  • Custom cell content (e.g. a row of custom widgets) can use role="row"/role="cell" if you must break from native table elements — prefer native elements whenever possible.

When to use

Use for structured data with multiple attributes — user lists, transactions, inventory. Best when users need to compare, sort, or scan data.

Do:

  • Right-align numeric columns
  • Include sortable headers where it helps
  • Use the striped variant for dense data
  • Keep columns to 8 or fewer

Don't:

  • Use a table for page layout
  • Show 20+ rows without pagination
  • Truncate critical data