@zendeskgarden/react-tables package provides a composable set of table components. Build data tables with sticky headers, sortable columns, row selection, overflow menus, and more.
Installation
Place a
ThemeProvider from @zendeskgarden/react-theming at the root of your React application. All Garden components must be rendered inside a ThemeProvider.Usage
Basic table
Sortable columns
UseTable.SortableCell in the header row to make columns sortable. Set sort to "asc" or "desc" to indicate the current sort direction.
Row selection and striping
Overflow actions
AddTable.OverflowButton inside a cell that has hasOverflow to display a row-level action menu trigger.
Table
The root<table> element. Provides size context to all child components.
Props
Sets the row density for the entire table.
Removes interactive hover and focus styling from rows. Use for display-only tables.
Table.Head
Wraps the<thead> section of the table.
Props
Makes the header row stick to the top of the viewport when scrolling a long table.
Table.HeaderRow
Renders a<tr> inside Table.Head. Accepts all standard HTMLAttributes<HTMLTableRowElement> props.
Table.HeaderCell
Renders a<th> cell in the header row.
Props
Applies minimum fixed-width styling. Use for checkbox or icon columns.
Truncates long text with an ellipsis.
Applies styling for a cell that contains an overflow menu button.
Sets the column width.
Table.Body
Wraps the<tbody> section of the table. Accepts all standard HTMLAttributes<HTMLTableSectionElement> props.
Table.Row
Renders a<tr> inside Table.Body.
Props
Applies selected row styling (highlighted background).
Applies alternating striped row styling.
Table.Cell
Renders a<td> cell inside a body row.
Props
Applies minimum fixed-width styling. Use for checkbox or icon columns.
Truncates long text with an ellipsis.
Applies styling for a cell that contains an overflow menu button.
Sets the cell width.
Table.SortableCell
Renders a header cell with a built-in sort button and sort direction icon. Managesaria-sort automatically.
Props
The current sort direction. When
undefined, a neutral sort icon is shown.Sets the column width.
Props forwarded to the underlying
<th> cell element (supports isMinimum, isTruncated, hasOverflow).Table.OverflowButton
Renders a vertical three-dot icon button intended for row-level overflow menus. Inherits its size from theTable context.
Table.OverflowButton accepts all standard ButtonHTMLAttributes<HTMLButtonElement> props.
Table.Caption
Renders an accessible<caption> element for the table. Captions are visually associated with the table and announced by screen readers.
Table.GroupRow
Renders a group header row spanning all columns, useful for grouping related rows withinTable.Body.
Exports
The following are exported from@zendeskgarden/react-tables:
| Export | Description |
|---|---|
Table | Root table element with all subcomponents attached |
Table.Head | <thead> wrapper |
Table.HeaderRow | <tr> inside the header |
Table.HeaderCell | <th> header cell |
Table.Body | <tbody> wrapper |
Table.Row | <tr> body row |
Table.Cell | <td> body cell |
Table.SortableCell | Sortable <th> with built-in sort button |
Table.OverflowButton | Row-level overflow menu trigger |
Table.Caption | Accessible table caption |
Table.GroupRow | Group header row |