Components
Table
A responsive data table built from semantic HTML. Supports captions, footers, and row selection states.
| Name | Role | |
|---|---|---|
| John Doe | john@example.com | Admin |
| Jane Smith | jane@example.com | User |
Import
import {
AppTable,
AppTableHeader,
AppTableBody,
AppTableFooter,
AppTableHead,
AppTableRow,
AppTableCell,
AppTableCaption,
} from "@/components/primitives/AppTable"With caption
Place AppTableCaption as the first child of AppTable. It renders below the table body via the caption-bottom utility regardless of DOM order.
| Invoice | Status | Amount |
|---|---|---|
| INV-001 | Paid | $250.00 |
| INV-002 | Pending | $150.00 |
| INV-003 | Paid | $350.00 |
With footer
Use AppTableFooter for summary rows — totals, counts, or aggregates. It renders with a top border and muted background automatically. Use colSpan on AppTableCell to span multiple columns.
| Invoice | Status | Amount |
|---|---|---|
| INV-001 | Paid | $250.00 |
| INV-002 | Pending | $150.00 |
| INV-003 | Paid | $350.00 |
| Total | $750.00 | |
Selected row
Add data-state="selected" to an AppTableRow to apply the selection highlight. Control this via your own state — no built-in selection logic is included.
| Name | Role | |
|---|---|---|
| John Doe | john@example.com | Admin |
| Jane Smith | jane@example.com | User |
| Bob Johnson | bob@example.com | Editor |
API Reference
AppTable
Extends all native <table> HTML attributes. Renders inside a overflow-auto wrapper — the className prop targets the inner <table>, not the wrapper.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Additional Tailwind classes merged onto the <table> element via cn(). |
AppTableHeader
Extends all native <thead> HTML attributes. Default styling applies a bottom border to all child rows.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Merged onto <thead>. Default: [&_tr]:border-b. |
AppTableBody
Extends all native <tbody> HTML attributes. Default styling removes the bottom border from the last row.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Merged onto <tbody>. Default: [&_tr:last-child]:border-0. |
AppTableFooter
Extends all native <tfoot> HTML attributes. Renders with a top border, muted background, and medium font weight.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Merged onto <tfoot>. Default: border-t bg-muted/50 font-medium [&>tr]:last:border-b-0. |
AppTableHead
Extends all native <th> HTML attributes. Used inside AppTableRow within AppTableHeader.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Merged onto <th>. Default: h-10 px-2 text-left align-middle font-medium text-muted-foreground. |
AppTableRow
Extends all native <tr> HTML attributes. Includes hover and selection transitions by default.
| Prop | Type | Default | Description |
|---|---|---|---|
| data-state | "selected" | undefined | — | Set to "selected" to apply the selection highlight (bg-muted). Controlled by your state — no built-in selection logic. |
| className | string | — | Merged onto <tr>. Default: border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted. |
AppTableCell
Extends all native <td> HTML attributes. Used inside AppTableRow within AppTableBody or AppTableFooter.
| Prop | Type | Default | Description |
|---|---|---|---|
| colSpan | number | — | Span multiple columns. Common in footer summary rows. |
| className | string | — | Merged onto <td>. Default: p-2 align-middle. |
AppTableCaption
Extends all native <caption> HTML attributes. Always place as the first child of AppTable. Renders below the table body via caption-bottom.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Merged onto <caption>. Default: mt-4 text-sm text-muted-foreground. Renders below body via caption-bottom. |
Source
"use client"
import * as React from "react"
import { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow } from "../ui/table"
type AppTableProps = React.ComponentProps<typeof Table>
function AppTable(props: AppTableProps) {
return <Table {...props} />
}
type AppTableHeaderProps = React.ComponentProps<typeof TableHeader>
function AppTableHeader(props: AppTableHeaderProps) {
return <TableHeader {...props} />
}
type AppTableBodyProps = React.ComponentProps<typeof TableBody>
function AppTableBody(props: AppTableBodyProps) {
return <TableBody {...props} />
}
type AppTableFooterProps = React.ComponentProps<typeof TableFooter>
function AppTableFooter(props: AppTableFooterProps) {
return <TableFooter {...props} />
}
type AppTableHeadProps = React.ComponentProps<typeof TableHead>
function AppTableHead(props: AppTableHeadProps) {
return <TableHead {...props} />
}
type AppTableRowProps = React.ComponentProps<typeof TableRow>
function AppTableRow(props: AppTableRowProps) {
return <TableRow {...props} />
}
type AppTableCellProps = React.ComponentProps<typeof TableCell>
function AppTableCell(props: AppTableCellProps) {
return <TableCell {...props} />
}
type AppTableCaptionProps = React.ComponentProps<typeof TableCaption>
function AppTableCaption(props: AppTableCaptionProps) {
return <TableCaption {...props} />
}
export {
AppTable, type AppTableProps,
AppTableHeader, type AppTableHeaderProps,
AppTableBody, type AppTableBodyProps,
AppTableFooter, type AppTableFooterProps,
AppTableHead, type AppTableHeadProps,
AppTableRow, type AppTableRowProps,
AppTableCell, type AppTableCellProps,
AppTableCaption, type AppTableCaptionProps,
}