Components
Table
A styled HTML table component with header, body, row dividers, and cell sub-components. Works well with @tanstack/react-table for sorting, selection, and pagination.
Installation
bunx @happlyui/cli@latest add table
Dependencies
Registry dependencies
These are automatically installed when you add this component.
happly-ui-utilsdivider
Usage
import * as Table from "@/components/ui/table"
<Table.Root>
<Table.Header>
<Table.Row>
<Table.Head>Name</Table.Head>
<Table.Head>Email</Table.Head>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>John</Table.Cell>
<Table.Cell>john@example.com</Table.Cell>
</Table.Row>
</Table.Body>
</Table.Root>
Examples
Data Table
A full data table example with sortable columns, avatars, and action buttons using @tanstack/react-table.
Member name | Title | Status | |
|---|---|---|---|
James Brownjames@example.com | Marketing ManagerSince Aug, 2021 | Active | |
Sophia Williamssophia@example.com | HR AssistantSince Aug, 2021 | Active | |
Arthur Taylorarthur@example.com | Entrepreneur / CEOSince May, 2022 | Absent | |
Emma Wrightemma@example.com | Front-end DeveloperSince Sep, 2022 | Active | |
Matthew Johnsonmatthew@example.com | Data Software EngineerSince Feb, 2022 | Active | |
Laura Perezlaura@example.com | Fashion DesignerSince Mar, 2022 | Absent | |
Wei Chenwei@example.com | Operations ManagerSince July, 2021 | Active |
<Table.Root>
<Table.Header>
<Table.Row>
<Table.Head>Member</Table.Head>
<Table.Head>Title</Table.Head>
<Table.Head>Status</Table.Head>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>...</Table.Cell>
</Table.Row>
<Table.RowDivider />
<Table.Row>
<Table.Cell>...</Table.Cell>
</Table.Row>
</Table.Body>
</Table.Root>
Numeric columns
Pass `numeric` to a header and its cells so figures align on their trailing edge with fixed-width digits.
| Invoice | Plan | Seats | Amount |
|---|---|---|---|
| INV-1042 | Team | 12 | $1,188.00 |
| INV-1041 | Starter | 3 | $99.00 |
| INV-1040 | Enterprise | 148 | $17,760.00 |
<Table.Head numeric>Amount</Table.Head>
<Table.Cell numeric>$1,188.00</Table.Cell>
Empty state
An empty table says what belongs here and how it gets filled, spanning every column.
| Invoice | Plan | Amount |
|---|---|---|
No invoices yet Invoices appear here once a subscription renews. | ||
<Table.Row>
<Table.Cell colSpan={3} className="h-32 text-center">
<p>No invoices yet</p>
<p>Invoices appear here once a subscription renews.</p>
</Table.Cell>
</Table.Row>
API Reference
Table.Root
The main table wrapper with horizontal scroll overflow.
| Prop | Type | Default | Description |
|---|
Table.Header
The table header section (thead).
| Prop | Type | Default | Description |
|---|
Table.Head
A table header cell with subtle background and rounded corners. Renders scope="col" by default.
| Prop | Type | Default | Description |
|---|---|---|---|
numeric | boolean | false | Aligns the column to the trailing edge and renders its digits at a fixed width (tabular-nums) |
scope | 'col' | 'row' | 'colgroup' | 'rowgroup' | 'col' | The cells this header applies to |
Table.Body
The table body section with configurable spacing from the header.
| Prop | Type | Default | Description |
|---|---|---|---|
spacing | number | 8 | Space in pixels between the header and body |
Table.Row
A table row with group hover support.
| Prop | Type | Default | Description |
|---|
Table.RowDivider
A visual divider row between table rows using the Divider component.
| Prop | Type | Default | Description |
|---|---|---|---|
dividerClassName | string | - | Additional class name for the inner Divider component |
Table.Cell
A table data cell with a 150ms hover background transition.
| Prop | Type | Default | Description |
|---|---|---|---|
numeric | boolean | false | Aligns the cell to the trailing edge and renders its digits at a fixed width (tabular-nums) |
Table.Caption
A table caption element.
| Prop | Type | Default | Description |
|---|