Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f6789d8
feat: add provisional Table component
rmartins90 Jul 23, 2026
d67c602
feat: rebuild Table as compound presentational primitives
frankieyan Aug 19, 2026
9b546cc
feat: make @tanstack/react-table a devDependency used only by stories
frankieyan Aug 19, 2026
d3d3be6
feat: match Table cell typography and spacing to the Figma
frankieyan Aug 19, 2026
59f1701
feat: apply Figma row states to selectable Table rows only
frankieyan Aug 19, 2026
70e07cb
feat: match Table column header styling and sort states to the Figma
frankieyan Aug 19, 2026
11a9260
docs: rebuild Table stories on the compound API and link the Figma de…
frankieyan Aug 19, 2026
a3d69c3
feat: align Table styling with the Figma table design
frankieyan Aug 19, 2026
f6ab054
docs: build Table stories from Reactist components and drop the story…
frankieyan Aug 19, 2026
47263ba
feat: add TableColumnGroup and TableColumn for sizing columns
frankieyan Aug 19, 2026
bb72f24
feat: default Table to tabular numerals
frankieyan Aug 19, 2026
5179521
feat: allow consumers to replace the Table sort icons
frankieyan Aug 19, 2026
630ff84
feat: replace the Table sort arrow and lighten the unsorted state
frankieyan Aug 19, 2026
f8f1ff0
fix: render TanStack cells with flexRender so the story type-checks o…
frankieyan Aug 19, 2026
4a20213
docs: remove the Table narrow viewport story
frankieyan Aug 19, 2026
273a6a4
test: drop the Table cell type style assertion
frankieyan Aug 19, 2026
e0ed634
fix: align Table content with logical start and end values
frankieyan Aug 19, 2026
d750fb0
fix: set aria-sort only on the sorted Table column
frankieyan Aug 19, 2026
c50e52a
feat: export the Table prop types
frankieyan Aug 19, 2026
2545798
refactor: drop the redundant Table display names
frankieyan Aug 19, 2026
c835100
refactor: inherit the Table font and text colour from the page
frankieyan Aug 19, 2026
ef410ed
refactor: build Table width and background from Box
frankieyan Aug 19, 2026
c446b67
fix: pad Table edge cells with logical properties
frankieyan Aug 19, 2026
5dc2f63
feat!: drop the per-column Table sortIcon prop
frankieyan Aug 19, 2026
b7e5b58
refactor: build the Table sort indicator classes with the object form
frankieyan Aug 19, 2026
4a6d103
docs: add a Table docs page
frankieyan Aug 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"@semantic-release/git": "10.0.1",
"@storybook/addon-docs": "10.5.7",
"@storybook/react-vite": "10.5.7",
"@tanstack/react-table": "9.1.2",
"@testing-library/dom": "10.4.1",
"@testing-library/jest-dom": "7.0.1",
"@testing-library/react": "16.3.2",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export * from './badge'
export * from './expansion-panel'
export * from './menu'
export * from './modal'
export * from './table'
export * from './tabs'
export * from './tooltip'

Expand Down
1 change: 1 addition & 0 deletions src/table/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './table'
14 changes: 14 additions & 0 deletions src/table/sort-indicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as React from 'react'

function SortIndicator() {
return (
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" focusable="false">
<path
d="M3.64645 7.85352C3.45118 7.65825 3.45118 7.34175 3.64645 7.14648L7.64645 3.14648C7.84171 2.95122 8.15822 2.95122 8.35348 3.14648L12.3535 7.14648C12.5487 7.34175 12.5487 7.65825 12.3535 7.85352C12.1582 8.04878 11.8417 8.04878 11.6464 7.85352L8.49996 4.70703V12.5498C8.49996 12.7983 8.2761 13 7.99996 13C7.72382 13 7.49996 12.7983 7.49996 12.5498V4.70703L4.35348 7.85352C4.15822 8.04878 3.84171 8.04878 3.64645 7.85352Z"
fill="currentColor"
/>
</svg>
)
}

export { SortIndicator }
78 changes: 78 additions & 0 deletions src/table/table.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { ArgTypes, Canvas, Markdown, Meta, Subtitle, Title } from '@storybook/addon-docs/blocks'

import { TableCell, TableColumn, TableColumnHeader } from './table'

import * as TableStories from './table.stories'

<Meta of={TableStories} />

<Title />

<Subtitle>Styled primitives for tabular data.</Subtitle>

## Overview

The `<Table>` component is a set of styled primitives on top of `<table>`, `<thead>`, `<tr>`, `<th>`, and `<td>`. It
handles the visual layer, e.g. column widths, spacing, dividers, row, and sort affordances, while leaving the data-source,
sort, and selection states to the consumer.

## Anatomy

The component is fully composable and consumers only need to include what they need. For example, if column headers are not
required, then `<TableHeader>` can be omitted.

<Markdown>{`
| Component | Renders | Responsibility |
| --- | --- | --- |
| \`<Table>\` | \`<table>\` | The full width table, and tabular figures styling |
| \`<TableColumnGroup>\` | \`<colgroup>\` | The column definitions, as the first child of \`<Table>\` |
| \`<TableColumn>\` | \`<col>\` | Defining the column's sizing |
| \`<TableHeader>\` | \`<thead>\` and its single \`<tr>\` | The header row |
| \`<TableColumnHeader>\` | \`<th>\` | The column label and its optional sort control |
| \`<TableBody>\` | \`<tbody>\` | The data rows |
| \`<TableRow>\` | \`<tr>\` | Row selection through \`aria-selected\` |
| \`<TableCell>\` | \`<td>\` | The data cells |
`}</Markdown>

## Basic usage

Render `<TableRow>`s and `<TableCell>` within `<Table>` and `<TableBody>` to render data. If consistent column sizing is needed,
define the columns in `<TableColumnGroup>`.

<Canvas of={TableStories.Default} />

## Props

Every component forwards its native attributes, except for the deprecated [`border`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/table#border),
[`width`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/col#width), and
[`align`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/td#align) attributes on `<Table>`, `<TableColumn>`, and
`<TableCell>`/`<TableColumnHeader>`, respectively. All components accept `exceptionallySetClassName` instead of `className`.

The three components below also include additional props:

### `<TableColumn>`

<ArgTypes of={TableColumn} />

### `<TableColumnHeader>`

<ArgTypes of={TableColumnHeader} />

### `<TableCell>`

<ArgTypes of={TableCell} />

## Row selection

Setting `aria-selected` on a `<TableRow>` would mark it as selected.

<Canvas of={TableStories.SelectedAndClickableRows} />

## With TanStack Table

The `<Table>` components do not dictate what external model layer they are used with. TanStack Table,
for example, would be a good option for driving the data, including
[sorting](https://tanstack.com/table/latest/docs/framework/react/guide/sorting) and
[pagination](https://tanstack.com/table/latest/docs/framework/react/guide/pagination).

<Canvas of={TableStories.TanStackIntegration} />
160 changes: 160 additions & 0 deletions src/table/table.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
.table {
font-variant-numeric: tabular-nums;
border-collapse: collapse;
}

.headerRow {
height: 40px;
border-bottom: 1px solid var(--product-library-border-idle-tint);
}

.headerCell {
height: 40px;
padding: 0 var(--reactist-spacing-small);
vertical-align: middle;
user-select: none;
}

.headerCellSortable {
padding: 0;
}

.sortButton {
display: flex;
gap: var(--reactist-spacing-xsmall);
align-items: center;
width: 100%;
height: 40px;
padding: 0 var(--reactist-spacing-small);
border: 0;
color: inherit;
font: inherit;
text-align: inherit;
background: transparent;
cursor: pointer;
}

.headerLabel {
flex: 1 0 0;
min-width: 0;
}

.sortButton:hover {
background-color: var(--product-library-actionable-secondary-hover-fill);
}

.sortButton:focus-visible {
outline: 2px solid var(--product-library-display-primary-idle-tint);
outline-offset: -2px;
}

.sortButton:hover .sortIndicatorUnsorted,
.sortButton:focus-visible .sortIndicatorUnsorted {
opacity: 1;
}

.row {
height: 48px;
background-color: var(--product-library-background-base-primary);
border-bottom: 1px solid var(--product-library-divider-primary);
}

.row[aria-selected] {
cursor: pointer;
}

.row[aria-selected]:hover {
background-color: var(--product-library-actionable-secondary-hover-fill);
border-bottom-color: var(--product-library-divider-tertiary);
}

.row[aria-selected='true'] {
background-color: var(--product-library-selectable-secondary-selected-fill);
}

.row[aria-selected]:focus-visible {
outline: 2px solid var(--product-library-divider-tertiary);
outline-offset: -2px;
}

.cell {
padding: var(--reactist-spacing-xsmall) var(--reactist-spacing-small);
vertical-align: middle;
}

.cell:first-child {
padding-inline-start: var(--reactist-spacing-medium);
}

.cell:last-child {
padding-inline-end: var(--reactist-spacing-medium);
}
Comment thread
frankieyan marked this conversation as resolved.

.sortIndicator {
display: inline-flex;
flex: none;
align-items: center;
justify-content: center;
color: var(--product-library-display-secondary-idle-tint);
}

.sortIndicatorUnsorted {
color: var(--product-library-display-tertiary-idle-tint);
opacity: 0;
}

.sortIndicatorDescending {
transform: rotate(180deg);
}

.align-start {
text-align: start;
}

.align-end {
text-align: end;
}

.columnWidth-auto {
width: auto;
}

.columnWidth-content {
width: 0;
}

.columnWidth-1-2 {
width: 50%;
}

.columnWidth-1-3 {
width: 33.3333%;
}

.columnWidth-2-3 {
width: 66.6667%;
}

.columnWidth-1-4 {
width: 25%;
}

.columnWidth-3-4 {
width: 75%;
}

.columnWidth-1-5 {
width: 20%;
}

.columnWidth-2-5 {
width: 40%;
}

.columnWidth-3-5 {
width: 60%;
}

.columnWidth-4-5 {
width: 80%;
}
Loading
Loading