Table

A semantic table component for displaying structured data with customizable styling, striped rows, and hover effects.

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:

<Table>
  <Table.Header>      {/* thead element */}
    <Table.Row>       {/* tr element */}
      <Table.HeaderCell />  {/* th element */}
    </Table.Row>
  </Table.Header>
  <Table.Body>        {/* tbody element */}
    <Table.Row>
      <Table.Cell />  {/* td element */}
    </Table.Row>
  </Table.Body>
  <Table.Footer />    {/* tfoot element */}
</Table>

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

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)#

PropTypeDefaultDescription
size"sm" | "md" | "lg"-Size of the table cells
stripedbooleanfalseAdd alternating row colors
hoverbooleanfalseAdd hover effect on rows
compactbooleanfalseReduce cell padding
align"left" | "center" | "right""left"Text alignment in cells

Table.HeaderCell (Th)#

PropTypeDefaultDescription
colSpannumber-Number of columns to span
rowSpannumber-Number of rows to span
scope"col" | "row"-Header cell scope

Table.Cell (Td)#

PropTypeDefaultDescription
colSpannumber-Number of columns to span
rowSpannumber-Number of rows to span
Customize Theme
Build your own sugarcoat/ui theme
PresetLime / Violet / Slate
Brand ColorLime
Accent ColorViolet
Gray ScaleSlate
Border RadiusLg