Skip to content

Table

A compound table component for displaying structured, tabular data with support for striped rows, adjustable density, and a sticky header.

Preview

NameRoleStatus
Alice MartinEngineerActive
Bob ChenDesignerAway
Carol DavisProductOffline

Compound pattern

Table uses a compound component pattern with five parts:

PartElementDescription
Table<table>Root wrapper
Table.Header<thead>Table head section
Table.Row<tr>A table row
Table.HeaderCell<th>Header cell
Table.Cell<td>Data cell

Features

  • Striped -- alternating row backgrounds for easier scanning.
  • Density -- compact, default, or comfortable padding.
  • Sticky header -- the header row stays fixed at the top of the scrollable container.

Props

Table

PropTypeDefaultDescription
stripedbooleanfalseAlternating row backgrounds
density'compact' | 'default' | 'comfortable''default'Row padding density
stickyHeaderbooleanfalseFixes the header during scroll
classNamestring--Additional CSS classes
childrenReact.ReactNode--Table content

Table.Header

PropTypeDefaultDescription
childrenReact.ReactNode--Header row(s)

Table.Row

PropTypeDefaultDescription
onClick() => void--Row click handler
childrenReact.ReactNode--Cells

Table.HeaderCell / Table.Cell

PropTypeDefaultDescription
align'left' | 'center' | 'right''left'Text alignment
widthstring | number--Column width
childrenReact.ReactNode--Cell content

Density reference

DensityPadding
compact8px 12px
default12px 16px
comfortable16px 20px

Code example

React

tsx
import { Table } from '@thepace/lexicon/components';

function UserTable() {
  return (
    <Table striped stickyHeader>
      <Table.Header>
        <Table.Row>
          <Table.HeaderCell>Name</Table.HeaderCell>
          <Table.HeaderCell>Role</Table.HeaderCell>
          <Table.HeaderCell align="right">Status</Table.HeaderCell>
        </Table.Row>
      </Table.Header>
      <tbody>
        <Table.Row>
          <Table.Cell>Alice Martin</Table.Cell>
          <Table.Cell>Engineer</Table.Cell>
          <Table.Cell align="right">Active</Table.Cell>
        </Table.Row>
        <Table.Row>
          <Table.Cell>Bob Chen</Table.Cell>
          <Table.Cell>Designer</Table.Cell>
          <Table.Cell align="right">Away</Table.Cell>
        </Table.Row>
      </tbody>
    </Table>
  );
}

Vanilla HTML

html
<table class="lex-table lex-table--striped lex-table--sticky-header">
  <thead class="lex-table__header">
    <tr class="lex-table__row">
      <th class="lex-table__header-cell">Name</th>
      <th class="lex-table__header-cell">Role</th>
      <th class="lex-table__header-cell" style="text-align: right">Status</th>
    </tr>
  </thead>
  <tbody>
    <tr class="lex-table__row">
      <td class="lex-table__cell">Alice Martin</td>
      <td class="lex-table__cell">Engineer</td>
      <td class="lex-table__cell" style="text-align: right">Active</td>
    </tr>
  </tbody>
</table>

CSS class reference

ClassPurpose
.lex-tableBase table styles
.lex-table--stripedAlternating row backgrounds
.lex-table--compactCompact density
.lex-table--comfortableComfortable density
.lex-table--sticky-headerSticky header
.lex-table__headerTable head
.lex-table__rowTable row
.lex-table__header-cellHeader cell
.lex-table__cellData cell

Released under the MIT License. A product by the pace.