bearnie

Table

Display structured tabular data.

NameStatusRole
AliceActiveAdmin
BobInactiveUser

Installation

npx bearnie add table
npx bearnie add table

Usage

import {
  Table,
  TableHeader,
  TableBody,
  TableRow,
  TableHead,
  TableCell,
} from "@/components/bearnie/table"
<Table>
  <TableHeader>
    <TableRow>
      <TableHead>Column</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell>Data</TableCell>
    </TableRow>
  </TableBody>
</Table>

Examples

With caption

A list of recent invoices.
InvoiceStatusAmount
INV001Paid$250.00
INV002Pending$150.00
ItemPrice
Product A$100.00
Product B$50.00
Total$150.00

With badges

NameStatusRole
Alice Johnson
Active
Admin
Bob Smith
Inactive
User

Sortable

Add sortable to a TableHead to make its column sortable. Clicking cycles ascending and descending. Values that look like numbers (including $1,200.50 or 45%) sort numerically, everything else alphabetically.

Status
Charlie$1,200.50Paid
Alice$250.00Paid
Bob$875.00Pending

Anatomy

  • Table - The root table element
  • TableHeader - Container for header rows
  • TableBody - Container for body rows
  • TableFooter - Container for footer rows
  • TableRow - A single table row
  • TableHead - Header cell
  • TableCell - Body/footer cell
  • TableCaption - Table caption text

Props

All Table components accept class for additional CSS classes. They are structural components wrapping native HTML table elements.

TableHead

Prop Type Default Description
sortable boolean false Render a sort button; clicking sorts the column ascending/descending