@usevyre/react @usevyre/vue

Table

A composable data table with sortable columns, striped rows, and multiple density variants. Built from semantic HTML table elements with accessible sort indicators.


Basic with sorting

Add sortable and sortDir to TableHeader for an accessible sort button with directional icons. Click the Name column header below to toggle sort direction.

RoleEmailStatus
Alice JohnsonAdminalice@example.comActive
Bob SmithEditorbob@example.comActive
Carol WhiteViewercarol@example.comInactive
Dave BrownEditordave@example.comActive
Team members — click Name to sort
import {
  Table, TableHead, TableBody, TableRow,
  TableHeader, TableCell, TableCaption
} from "@usevyre/react";

const [sortDir, setSortDir] = useState<"asc" | "desc" | null>(null);

<Table hoverable>
  <TableHead>
    <TableRow>
      <TableHeader sortable sortDir={sortDir} onSort={toggleSort}>Name</TableHeader>
      <TableHeader>Role</TableHeader>
      <TableHeader>Email</TableHeader>
      <TableHeader align="center">Status</TableHeader>
    </TableRow>
  </TableHead>
  <TableBody>
    {rows.map((row) => (
      <TableRow key={row.id}>
        <TableCell>{row.name}</TableCell>
        <TableCell>{row.role}</TableCell>
        <TableCell>{row.email}</TableCell>
        <TableCell align="center">{row.status}</TableCell>
      </TableRow>
    ))}
  </TableBody>
  <TableCaption>Team members</TableCaption>
</Table>

Variants

Mix striped, bordered, and compact props freely.

Striped

NameRoleStatus
Alice JohnsonAdminActive
Bob SmithEditorActive
Carol WhiteViewerInactive

Bordered + Compact

NameRoleStatus
Alice JohnsonAdminActive
Bob SmithEditorActive
Carol WhiteViewerInactive
{/* Striped rows */}
<Table striped>...</Table>

{/* Bordered cells */}
<Table bordered>...</Table>

{/* Compact padding */}
<Table compact>...</Table>

{/* Combined */}
<Table bordered compact>...</Table>

Props — Table

Props

Prop Type Default Description
striped boolean false Alternating row background colors.
bordered boolean false Borders on all cells.
compact boolean false Reduced cell padding.
hoverable boolean true Highlight row on hover.
class / className string Additional CSS class.

Props — TableHeader

Props

Prop Type Default Description
sortable boolean false Renders a sort button inside the header cell.
sortDir "asc" | "desc" | null null Current sort direction. Controls icon opacity.
onSort / @sort () => void Called when the sort button is clicked.
align "left" | "center" | "right" "left" Text alignment.
class / className string Additional CSS class.

Props — TableCell

Props

Prop Type Default Description
align "left" | "center" | "right" "left" Text alignment of the cell.
class / className string Additional CSS class.

Props — TableRow

Props

Prop Type Default Description
selected boolean false Highlights the row and sets aria-selected.
class / className string Additional CSS class.