Table

A semantic table for rows and columns.

Overview

Table renders a native table. It sets spacing, type, borders, and a horizontal scroll wrapper. It does not sort, filter, paginate, or store column state.

TableHead is a th. TableCaption is a caption. The other parts map to thead, tbody, tfoot, tr, and td.

Preview

NameRole
Ada LovelaceWriter
Grace HopperScientist

Installation

Add the component with the CLI. It copies the files in and installs anything they depend on.

npx vinyaas add table

Usage

import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; export function Team() { return ( <Table> <TableHeader> <TableRow> <TableHead>Name</TableHead> <TableHead>Role</TableHead> </TableRow> </TableHeader> <TableBody> <TableRow> <TableCell>Ada Lovelace</TableCell> <TableCell>Writer</TableCell> </TableRow> <TableRow> <TableCell>Grace Hopper</TableCell> <TableCell>Scientist</TableCell> </TableRow> </TableBody> </Table> ); }

Examples

Basic

Headers name the columns. Cells stay in the body.

NameRole
Ada LovelaceWriter
Grace HopperScientist

Caption

TableCaption is a native caption and names the table.

Team
NameRole
Ada LovelaceWriter
Grace HopperScientist

TableFooter is a native tfoot for a summary row.

NameRole
Ada LovelaceWriter
Grace HopperScientist
2 people

Resizable columns

Add resize: horizontal and overflow: hidden to TableHead to let the user drag column widths.

NameRoleDepartment
Ada LovelaceWriterComputing
Grace HopperScientistEngineering
Alan TuringMathematicianComputing

Responsive

A wide table scrolls inside its wrapper. The page itself does not scroll sideways.

NameRole
Ada LovelaceWriter
Grace HopperScientist

In practice

A team directory pairs Avatar, Badge status, search, and a row menu. The table stays semantic; the page owns filtering and actions.

Team members

People with access to this workspace.

UserRoleStatusActions
AS

Aarav Sharma

aarav@example.com

AdminActive
PS

Priya Singh

priya@example.com

EditorPending
AM

Aarav Mehta

aarav.mehta@example.com

ViewerDisabled

API

Other attributes for the underlying element are passed through.

NameTypeDefaultDescription
classNamestring—Merged onto the underlying table, row, cell, or caption.
childrenReactNode—The table sections, rows, and cells.

Accessibility

The parts are native table elements. The component does not add ARIA roles.

  • Give each column a TableHead.
  • Use TableCaption when the table needs an accessible name.
  • A wide table scrolls in its wrapper.