@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

PropTypeDefaultDescription
stripedbooleanfalseAlternating row background colors.
borderedbooleanfalseBorders on all cells.
compactbooleanfalseReduced cell padding.
hoverablebooleantrueHighlight row on hover.
class / classNamestringAdditional CSS class.

Props — TableHeader

Props

PropTypeDefaultDescription
sortablebooleanfalseRenders a sort button inside the header cell.
sortDir"asc" | "desc" | nullnullCurrent sort direction. Controls icon opacity.
onSort / @sort() => voidCalled when the sort button is clicked.
align"left" | "center" | "right""left"Text alignment.
class / classNamestringAdditional CSS class.

Props — TableCell

Props

PropTypeDefaultDescription
align"left" | "center" | "right""left"Text alignment of the cell.
class / classNamestringAdditional CSS class.

Props — TableRow

Props

PropTypeDefaultDescription
selectedbooleanfalseHighlights the row and sets aria-selected.
class / classNamestringAdditional CSS class.