Skip to main content

Overview

The table component library provides a complete set of primitives for building data tables with support for responsive layouts, custom styling, and loading states.

Components

TableSkeleton

The main table container component that provides layout structure, scrolling behavior, and loading states. Props:
PropTypeDefaultDescription
topJSX.Element | null-Header section (typically HeaderRow)
middleJSX.Element-Body content (typically BodyRow components)
bottomJSX.Element-Footer section (optional)
hideHeadersOnMobilebooleanfalseHide header on mobile viewports
isMobileboolean-Mobile viewport flag
noBorderbooleanfalseRemove outer border
noBgbooleanfalseRemove background color
notRoundedbooleanfalseRemove rounded corners
fillSpacebooleanfalseFill available vertical space
autoHeightbooleanfalseAutomatically adjust height to content
classNamestring-Custom CSS classes
innerClassNamestring-CSS classes for inner container
loadingbooleanfalseShow loading indicator
overflowAutoboolean-Enable auto overflow behavior
setIsScrollable(isScrollable: boolean) => void-Callback when scroll state changes
Example:
import { TableSkeleton, HeaderRow, BodyRow, HeaderCell, BodyCell } from '@drift-labs/common/react';

function DataTable({ data, loading }) {
  return (
    <TableSkeleton
      loading={loading}
      fillSpace
      top={
        <HeaderRow grid="grid-cols-3">
          <HeaderCell>Name</HeaderCell>
          <HeaderCell>Email</HeaderCell>
          <HeaderCell alignRight>Status</HeaderCell>
        </HeaderRow>
      }
      middle={
        <>
          {data.map((row) => (
            <BodyRow key={row.id} grid="grid-cols-3">
              <BodyCell>{row.name}</BodyCell>
              <BodyCell>{row.email}</BodyCell>
              <BodyCell alignRight>{row.status}</BodyCell>
            </BodyRow>
          ))}
        </>
      }
    />
  );
}
Source: ~/workspace/source/react/src/components/Tables/TableSkeleton.tsx:7

HeaderRow

Container component for table header cells. Props:
PropTypeDefaultDescription
gridstring-Required. Tailwind grid classes (e.g., “grid-cols-3”)
classNamestring-Custom CSS classes
forceBottomBorderbooleanfalseForce bottom border rendering
headerboolean-Header style flag
lastColumnJustifystring-Justify content for last column
idstring-Element ID
addScrollPaddingbooleanfalseAdd padding to account for scrollbar
childrenReactNode-Header cell components
Example:
<HeaderRow grid="grid-cols-4" addScrollPadding>
  <HeaderCell>Column 1</HeaderCell>
  <HeaderCell>Column 2</HeaderCell>
  <HeaderCell>Column 3</HeaderCell>
  <HeaderCell alignRight>Column 4</HeaderCell>
</HeaderRow>
Source: ~/workspace/source/react/src/components/Tables/HeaderRow.tsx:5

BodyRow

Container component for table body cells with hover effects. Props:
PropTypeDefaultDescription
gridstring-Required. Tailwind grid classes
classNamestring-Custom CSS classes
forceBottomBorderbooleanfalseForce bottom border
headerboolean-Header style flag
lastColumnJustifystring-Justify content for last column
isDataRowboolean-Adds data-puppet-tag for testing
noBorderbooleanfalseRemove border
onClick(event: MouseEvent) => void-Click handler
lastChildNoBorderboolean-Remove border from last child
strongBottomBorderboolean-Stronger bottom border
childrenReactNode-Body cell components
Example:
<BodyRow 
  grid="grid-cols-3" 
  isDataRow
  onClick={(e) => handleRowClick(row.id)}
>
  <BodyCell>{row.name}</BodyCell>
  <BodyCell>{row.email}</BodyCell>
  <BodyCell alignRight>{row.status}</BodyCell>
</BodyRow>
Source: ~/workspace/source/react/src/components/Tables/BodyRow.tsx:5

SummaryRow

Specialized row component for summary or totals rows. Props:
PropTypeDefaultDescription
gridstring-Required. Tailwind grid classes
classNamestring-Custom CSS classes
headerboolean-Header style flag
childrenReactNode-Cell components
Example:
<SummaryRow grid="grid-cols-3">
  <BodyCell>Total</BodyCell>
  <BodyCell></BodyCell>
  <BodyCell alignRight>$1,234.56</BodyCell>
</SummaryRow>
Source: ~/workspace/source/react/src/components/Tables/SummaryRow.tsx:5

HeaderCell

Individual header cell component. Props:
PropTypeDefaultDescription
classNamestring-Custom CSS classes
alignRightbooleanfalseRight-align content
childrenReactNode-Cell content
Example:
<HeaderCell className="font-bold">Name</HeaderCell>
<HeaderCell alignRight>Amount</HeaderCell>
Source: ~/workspace/source/react/src/components/Tables/HeaderCell.tsx:4

BodyCell

Individual body cell component with flexible layout options. Props:
PropTypeDefaultDescription
classNamestring-Custom CSS classes for outer wrapper
innerClassNamestring-Custom CSS classes for inner content
onClick() => void-Click handler
dataPuppetTagstring-Test automation identifier
flexColbooleanfalseUse flex column layout
alignCenterbooleanfalseCenter-align content
alignRightbooleanfalseRight-align content
childrenReactNode-Cell content
Example:
<BodyCell alignRight onClick={() => handleClick()}>$99.99</BodyCell>
<BodyCell flexCol alignCenter>
  <Icon />
  <span>Label</span>
</BodyCell>
Source: ~/workspace/source/react/src/components/Tables/BodyCell.tsx:4

TableCellCardValue

Specialized cell component for card-style mobile layouts with label and value. Props:
PropTypeDefaultDescription
valueReactNode-Required. Cell value content
labelstring-Required. Label text
iconJSX.Element-Optional icon element
size'xs' | 'sm' | 'md' | 'lg' | 'xl'-Text size
highlightbooleanfalseApply highlight styling (larger text)
isMobileTopRowbooleanfalseAdjust padding for first mobile row
classNamestring-Custom CSS classes
onClick() => void-Click handler
Example:
<TableCellCardValue
  label="Total Amount"
  value="$1,234.56"
  size="lg"
  highlight
  icon={<DollarIcon />}
/>
Source: ~/workspace/source/react/src/components/Tables/TableCellCardValue.tsx:4

Complete Example

Here’s a complete example showing responsive table with loading state:
import {
  TableSkeleton,
  HeaderRow,
  BodyRow,
  SummaryRow,
  HeaderCell,
  BodyCell,
  TableCellCardValue
} from '@drift-labs/common/react';

function UserTable({ users, loading, isMobile }) {
  const totalUsers = users.length;

  return (
    <TableSkeleton
      loading={loading}
      isMobile={isMobile}
      hideHeadersOnMobile
      fillSpace
      top={
        <HeaderRow grid="grid-cols-4" addScrollPadding>
          <HeaderCell>Name</HeaderCell>
          <HeaderCell>Email</HeaderCell>
          <HeaderCell>Role</HeaderCell>
          <HeaderCell alignRight>Status</HeaderCell>
        </HeaderRow>
      }
      middle={
        <>
          {users.map((user) => (
            <BodyRow 
              key={user.id} 
              grid="grid-cols-4"
              isDataRow
            >
              {isMobile ? (
                <BodyCell flexCol>
                  <TableCellCardValue label="Name" value={user.name} />
                  <TableCellCardValue label="Email" value={user.email} />
                  <TableCellCardValue label="Role" value={user.role} />
                  <TableCellCardValue label="Status" value={user.status} />
                </BodyCell>
              ) : (
                <>
                  <BodyCell>{user.name}</BodyCell>
                  <BodyCell>{user.email}</BodyCell>
                  <BodyCell>{user.role}</BodyCell>
                  <BodyCell alignRight>{user.status}</BodyCell>
                </>
              )}
            </BodyRow>
          ))}
        </>
      }
      bottom={
        <SummaryRow grid="grid-cols-4">
          <BodyCell>Total Users</BodyCell>
          <BodyCell></BodyCell>
          <BodyCell></BodyCell>
          <BodyCell alignRight>{totalUsers}</BodyCell>
        </SummaryRow>
      }
    />
  );
}

Styling

All table components use Tailwind CSS and can be customized via className props. The components use tailwind-merge to intelligently combine custom classes with defaults.

Grid Layouts

Table rows use CSS Grid for column layouts. Specify grid classes using the grid prop:
// 3 equal columns
<HeaderRow grid="grid-cols-3">

// Custom column widths
<HeaderRow grid="grid-cols-[200px_1fr_100px]">

// Responsive columns
<HeaderRow grid="grid-cols-1 md:grid-cols-3">

Accessibility

Table components support:
  • Semantic HTML structure
  • Keyboard navigation through interactive elements
  • ARIA labels via custom props
  • Screen reader friendly content
Also exported from the Tables module:
  • BodyCellWrapper - Lower-level cell wrapper
  • HeaderCellWrapper - Lower-level header wrapper
  • BodyRowWrapper - Lower-level row wrapper
  • TableRowWrapper - Generic row wrapper

Build docs developers (and LLMs) love