Import
import { Table } from "@sugarcoat/ui-nxt";Usage
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Name</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>Value</Table.Cell>
</Table.Row>
</Table.Body>
</Table>Basic Usage#
A simple table with headers and data rows.
Basic Table
Anatomy#
The Table component uses a compound component pattern:
Aliases: Table.Thead, Table.Tbody, Table.Tfoot, Table.Tr, Table.Th, Table.Td
Sizes#
Tables come in three sizes: sm, md (default), and lg.
Small
Medium
Large
Striped Rows#
Add alternating row colors for better readability.
Striped
Hover Effect#
Add hover highlighting to rows.
Hover
Compact Mode#
Use compact mode for denser data display.
Compact
Text Alignment#
Control text alignment with left, center, or right.
Left Aligned
Center Aligned
Right Aligned
With Footer#
Tables can include a footer section for totals or summaries.
With Footer
Combined Features#
Use multiple features together for rich table displays.
Combined
Using Aliases#
The Table component provides shorter aliases for convenience.
Using Aliases
Props#
Table (Root)#
| Prop | Type | Default | Description |
|---|---|---|---|
| size | "sm" | "md" | "lg" | - | Size of the table cells |
| striped | boolean | false | Add alternating row colors |
| hover | boolean | false | Add hover effect on rows |
| compact | boolean | false | Reduce cell padding |
| align | "left" | "center" | "right" | "left" | Text alignment in cells |
Table.HeaderCell (Th)#
| Prop | Type | Default | Description |
|---|---|---|---|
| colSpan | number | - | Number of columns to span |
| rowSpan | number | - | Number of rows to span |
| scope | "col" | "row" | - | Header cell scope |
Table.Cell (Td)#
| Prop | Type | Default | Description |
|---|---|---|---|
| colSpan | number | - | Number of columns to span |
| rowSpan | number | - | Number of rows to span |