Skip to content

Data table

Pro

Browse, sort, filter, select and act on records, from the browser or a server, with saved views and a compact form. Not an M3 component (@windmorph/react-pro).

import { DataTable, DataTableToolbar, DataTableView, DataTablePagination, DataTableFilterChips, DataTableFilterDialog, DataTableColumnSettings, useDataTable } from '@windmorph/react-pro';

Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.

Props

By name or description, across the 99 props below

DataTable 40 props

  • columnstype readonly ColumnDef<Row>[]Required

    The columns.

  • rowstype readonly Row[]Required

    Client mode: every row. Server mode: the current page.

  • getRowIdtype (row: Row) => stringRequired

    A row's unique id.

  • modetype "client" | "server"default "client"

    client sorts, filters and pages rows (a guide of up to about 5,000); server reports onStateChange and the app supplies the page and totalRows.

  • totalRowstype number

    Server mode: how many rows match the current search and filters.

  • statetype TableState

    The state (controlled, with onStateChange), for fetching pages or saving views.

  • defaultStatetype Partial<TableState>

    The state to start from, when uncontrolled.

  • plaintype booleandefault false

    A list of 4 to 20 rows with no toolbar, search, filters, column settings or pagination.

  • selectionModetype "none" | "single" | "multiple"default "none"

    How rows are selected.

  • rowSelectabletype ((row: Row) => boolean)

    Whether a row can be selected.

  • bulkActionstype ((selection: { ids: string[]; allMatching: boolean; }) => ReactNode)

    The bulk bar's actions while rows are selected.

  • rowActionstype ((row: Row) => DataTableRowAction[])

    A row's menu of actions.

  • rowHreftype ((row: Row) => string)

    Makes each row a link, working before the page's script loads.

  • pageSizestype readonly number[]default [25, 50, 100]

    The rows-per-page choices.

  • maxSortLevelstype numberdefault 3

    How many columns can sort at once.

  • compactBelowtype DataTableCompactBelowdefault "medium"

    The width class below which the table becomes a list.

  • renderCompactRowtype ((row: Row) => DataTableCompactRow)default the row header, and the next column that isn't end-aligned as supporting text; with none, every other column's name and value

    What a compact row shows.

  • maxHeighttype DataTableMaxHeightdefault as tall as the rows

    The rows' greatest height, px or any CSS length: past it they scroll under the header (a list's rows scroll too), and a scroller with nothing to move through takes focus so the keyboard can scroll it.

  • filterstype ReactNode

    The app's own filters, beside the search.

  • chipstype readonly DataTableExtraChip[]

    The app's own active filters, shown as chips.

  • actionstype ReactNode

    The app's actions on the table, at the toolbar's end.

  • loadingtype booleandefault false

    Shows loading rows, or a progress bar over rows already there.

  • errortype ReactNode

    A message to show in place of the rows.

  • emptytype ReactNodedefault an EmptyState with labels.empty

    Shown when no rows match.

  • densitytype 0 | -1 | -2 | -3default the theme's

    The table's own density.

  • iconstype Partial<DataTableIcons>

    Replaces icons.

  • reftype Ref<HTMLDivElement>

    Ref to the outermost element.

  • idtype string

    The outermost element's id.

Events

  • onStateChangetype ((state: TableState) => void)

    Called with the whole state when anything changes.

  • onRowActiontype ((row: Row) => void)

    Called when a row is activated.

  • onClearFilterstype (() => void)default the column filters

    Clears the app's filters and the column filters at once.

  • onRetrytype (() => void)

    Adds a retry button to the error.

Text

  • labelstype Partial<DataTableLabels>

    Words it shows or announces. A LabelsProvider sets them for the whole app.

  • aria-labeltype string

    One of aria-label or aria-labelledby is required.

  • aria-labelledbytype string

    One of aria-label or aria-labelledby is required.

  • aria-describedbytype string

    The id of an element that describes it.

  • aria-detailstype string

    The id of an element with more detail about it.

Also accepts the root element's HTML attributes (id, data-*, event handlers).

DataTableToolbar 10 props

  • tabletype DataTableController<Row>Required

    What useDataTable returned.

  • filterstype ReactNode

    The app's own filters, beside the search.

  • actionstype ReactNode

    The app's actions on the table, at the toolbar's end.

  • bulkActionstype ((selection: { ids: string[]; allMatching: boolean; }) => ReactNode)

    The bulk bar's actions while rows are selected.

  • compactBelowtype DataTableCompactBelowdefault "medium"

    The width class below which the column settings button hides.

  • reftype Ref<HTMLDivElement>

    Ref to the part's outermost element.

  • idtype string

    The part's outermost element's id.

DataTableView 23 props

  • tabletype DataTableController<Row>Required

    What useDataTable returned.

  • selectionModetype "none" | "single" | "multiple"default "none"

    How rows are selected.

  • rowSelectabletype ((row: Row) => boolean)

    Whether a row can be selected.

  • rowActionstype ((row: Row) => DataTableRowAction[])

    A row's menu of actions.

  • rowHreftype ((row: Row) => string)

    Makes each row a link, working before the page's script loads.

  • maxSortLevelstype numberdefault 3

    How many columns can sort at once.

  • compactBelowtype DataTableCompactBelowdefault "medium"

    The width class below which the table becomes a list.

  • renderCompactRowtype ((row: Row) => DataTableCompactRow)default the row header, and the next column that isn't end-aligned as supporting text; with none, every other column's name and value

    What a compact row shows.

  • maxHeighttype DataTableMaxHeightdefault as tall as the rows

    The rows' greatest height, px or any CSS length: past it they scroll under the header (a list's rows scroll too), and a scroller with nothing to move through takes focus so the keyboard can scroll it.

  • loadingtype booleandefault false

    Shows loading rows, or a progress bar over rows already there.

  • errortype ReactNode

    A message to show in place of the rows.

  • emptytype ReactNodedefault an EmptyState with labels.empty

    Shown when no rows match.

  • reftype Ref<HTMLDivElement>

    Ref to the part's outermost element.

  • idtype string

    The part's outermost element's id.

Events

  • onRowActiontype ((row: Row) => void)

    Called when a row is activated.

  • onRetrytype (() => void)

    Adds a retry button to the error.

Text

  • aria-labeltype string

    One of aria-label or aria-labelledby is required.

  • aria-labelledbytype string

    One of aria-label or aria-labelledby is required.

  • aria-describedbytype string

    The id of an element that describes it.

  • aria-detailstype string

    The id of an element with more detail about it.

DataTablePagination 6 props

  • tabletype DataTableController<Row>Required

    What useDataTable returned.

  • reftype Ref<HTMLDivElement>

    Ref to the part's outermost element.

  • idtype string

    The part's outermost element's id.

DataTableFilterChips 8 props

  • tabletype DataTableController<Row>Required

    What useDataTable returned.

  • chipstype readonly DataTableExtraChip[]

    The app's own active filters, shown as chips.

  • reftype Ref<HTMLDivElement>

    Ref to the part's outermost element.

  • idtype string

    The part's outermost element's id.

Events

  • onClearFilterstype (() => void)default the column filters

    Clears the app's filters and the column filters at once.

DataTableFilterDialog 6 props

  • tabletype DataTableController<Row>Required

    What useDataTable returned.

  • reftype Ref<HTMLDivElement>

    Ref to the part's outermost element.

  • idtype string

    The part's outermost element's id.

DataTableColumnSettings 6 props

  • tabletype DataTableController<Row>Required

    What useDataTable returned.

  • reftype Ref<HTMLDivElement>

    Ref to the part's outermost element.

  • idtype string

    The part's outermost element's id.

Types

ColumnDef 20 fields

A column definition, shared by DataTable and DataGrid.

  • idtype stringRequired

    Unique within the table.

  • headertype stringRequired

    Shown above the column and in column settings. Never empty: screen readers name it.

  • accessortype (row: Row) => ColumnValueRequired

    The value used to sort, search, filter and display by default.

  • celltype (row: Row) => React.ReactNodedefault the formatted accessor value

    Custom cell content.

  • typetype ColumnTypedefault "text"

    Formats the value when there is no cell, right-aligning numbers.

  • currencytype stringdefault "USD"

    With type="currency", the ISO 4217 code.

  • formattype (value: ColumnValue, row: Row) => string

    Replaces the type's formatting.

  • aligntype "start" | "center" | "end"default "end" for numbers and currency, else "start"

    Alignment of the header and cells.

  • widthtype number | "fit"default 180

    Width, px, or 'fit' for the widest of its header and values plus the cell padding, within minWidth and maxWidth. A person's resize wins over either. A cell that wraps or grows with its box (several tags, a progress bar) should set a number instead.

  • minWidthtype numberdefault 80

    Least width, px.

  • maxWidthtype number

    Greatest width, px.

  • growtype booleandefault false

    Shares the table's spare width in proportion to its width.

  • rowHeadertype booleandefault true for the first column, when none is set

    Announced with each row.

  • sortabletype booleandefault true, or false in plain

    Whether a press on the header sorts.

  • hideabletype booleandefault true

    Whether people can hide it.

  • pinnabletype booleandefault true

    Whether people can pin it.

  • reorderabletype booleandefault true

    Whether people can reorder it.

  • resizabletype booleandefault true

    Whether people can resize it.

  • filtertype ColumnFilter

    How people filter it, if they can.

  • searchabletype booleandefault true while it is shown, false while hidden

    Whether search reads it.

TableState 9 fields

Everything a person can change about a table, serializable so an app can save it as a view.

  • columnOrdertype string[]Required

    Column ids, in order.

  • hiddentype string[]Required

    The ids of the hidden columns.

  • widthstype Record<string, number>Required

    Widths a person set, by column id, in px.

  • pinnedtype { start: string[]; end: string[]; }Required

    Columns kept in view as the rest scroll sideways.

  • sorttype SortLevel[]Required

    Sort levels in order; empty for the rows as given.

  • filterstype Record<string, FilterValue>Required

    Filters by column id.

  • pagetype { index: number; size: number; }Required

    The zero-based page and how many rows it holds.

  • selectiontype { ids: string[]; allMatching: boolean; }Required

    Selected row ids, kept across pages; allMatching covers every row matching the filters.

DataTableRowAction 4 fields

One action in a row's menu.

  • idtype stringRequired

    Unique within the row’s menu.

  • labeltype stringRequired

    The menu item’s words.

  • disabledtype boolean

    Whether it can be chosen.

  • onActiontype () => voidRequired

    Called when it’s chosen.

DataTableCompactRow 4 fields

What a row shows in the compact form.

  • headlinetype React.ReactNodeRequired

    The row’s main text.

  • supportingTexttype string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal | Promise<AwaitedReactNode>

    A second line.

  • leadingtype string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal | Promise<AwaitedReactNode>

    Content before the text.

  • trailingtype string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal | Promise<AwaitedReactNode>default the row’s actions menu

    Content after the text.

DataTableExtraChip 3 fields

A filter the page keeps itself, shown as a chip beside the column filters.

  • keytype stringRequired

    Unique among the chips.

  • labeltype stringRequired

    The chip’s words.

  • onRemovetype () => voidRequired

    Called when it’s removed.

Hooks

useDataTable

useDataTable signature
useDataTable(options: UseDataTableOptions<Row>): DataTableController<Row>

A data table's state and rows, for composing its parts differently from DataTable. Not an M3 component (Windmorph Pro, docs/plans/data-table.md).

  • optionstype UseDataTableOptions<Row>Required
  • options.columnstype readonly ColumnDef<Row>[]Required

    The columns.

  • options.rowstype readonly Row[]Required

    Client mode: every row. Server mode: the current page.

  • options.getRowIdtype (row: Row) => stringRequired

    A row's unique id.

  • options.modetype "client" | "server"default "client"

    client sorts, filters and pages rows (a guide of up to about 5,000); server reports onStateChange and the app supplies the page and totalRows.

  • options.totalRowstype number

    Server mode: how many rows match the current search and filters.

  • options.statetype TableState

    The state (controlled, with onStateChange), for fetching pages or saving views.

  • options.defaultStatetype Partial<TableState>

    The state to start from, when uncontrolled.

  • options.onStateChangetype (state: TableState) => void

    Called with the whole state when anything changes.

  • options.plaintype booleandefault false

    Every row on one page, with no paging.

  • options.pageSizestype readonly number[]default [25, 50, 100]

    The rows-per-page choices.

  • options.loadingtype booleandefault false

    Whether rows are on their way, so a page past the end isn't corrected yet.

  • options.iconstype Partial<DataTableIcons>

    Replaces icons.

  • options.labelstype Partial<DataTableLabels>

    Words it shows or announces. A LabelsProvider sets them for the whole app.

Returns DataTableController<Row>

  • columnstype readonly ColumnDef<Row>[]Required

    Every column.

  • shownColumnstype ColumnDef<Row>[]Required

    The columns showing, in order.

  • rowstype readonly Row[]Required

    The rows of the current page.

  • allRowstype readonly Row[]Required

    Every row given, before search, filters and paging: what client-mode width: 'fit' measures.

  • getRowIdtype (row: Row) => stringRequired

    A row’s unique id.

  • modetype "client" | "server"Required

    Where sorting, filtering and paging happen.

  • plaintype booleanRequired

    Whether it’s the plain form.

  • pageSizestype readonly number[]Required

    The rows-per-page choices.

  • totaltype numberRequired

    How many rows match.

  • statetype TableStateRequired

    The whole state.

  • pagetype { index: number; size: number; }Required

    The page shown, moved back when the total shrank below it.

  • updatetype (patch: Partial<TableState>) => voidRequired

    Merges a change into the state.

  • setSearchtype (search: string) => voidRequired

    Applies a search, from the first page and with nothing selected.

  • setFiltertype (columnId: string, value: FilterValue | null) => voidRequired

    Sets or, with null, removes a column's filter.

  • clearFilterstype () => voidRequired

    Removes every column filter.

  • resetColumnstype () => voidRequired

    Puts column order, visibility, widths and pins back as they started.

  • filteringColumntype ColumnDef<Row> | undefinedRequired

    The column whose filter dialog is open.

  • openFiltertype (columnId: string | null) => voidRequired

    Opens a column's filter dialog, or closes it with null.

  • columnSettingsOpentype booleanRequired

    Whether the column settings dialog is open.

  • setColumnSettingsOpentype (open: boolean) => voidRequired

    Opens or closes the column settings dialog.

  • sortMessagetype stringRequired

    The last sort change, for the polite live region.

  • announceSorttype (message: string) => voidRequired

    Sets the message for the polite live region.

  • localetype stringRequired

    The locale values are formatted in.

  • formattype { number: (value: number) => string; day: (iso: string) => string; cell<Row>(column: ColumnDef<Row>, row: Row): string; }Required

    Formats cell values for that locale.

  • labelstype DataTableLabelsRequired

    Every word, with the app’s overrides.

  • iconstype DataTableIconsRequired

    Every icon, with the app’s overrides.

Spec status

Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.

  • Search, multi-column sort, filters and saved views

    Built

    Configuration · Tools

  • Row selection, with bulk actions across pages (selectionMode, bulkActions)

    Built

    Configuration · Selection

  • Server-side data (mode="server", totalRows)

    Built

    Configuration · Server

  • A plain, read-only table (plain)

    Built

    Variant · Plain

  • Pinned columns

    Built

    Configuration · Pinned

  • Columns that fit their content (width: 'fit'), fixed and growing widths

    Built

    Configuration · Widths

Theming & tokens

Set the tokens below on the table or any ancestor. Its fields, buttons and menus are the core's, so they keep their own tokens. Style each part with classNames: root, toolbar, search, filterButton, actions, columnsButton, bulkBar, bulkCount, bulkActions, chips, chip, clearAll, container, table, header, headerRow, headerCell, headerContent, headerLabel, sortIcon, sortLevel, resizer, resizerLine, body, row, cell, rowLink, selectionCell, selectionCheckbox, actionsCell, actionButton, pagination, pageSize, range, pageButtons, pageButton, pageIcon, compactList, compactRow, compactFigure, loading, skeletonRow, skeletonRows, skeletonCell, progress, empty, error, columnSettings, settingsRow, settingsName, filterDialog, filterFields, filterRange.

DataTable tokens
VariableDefaultPaints
--wm-data-table-container-colorvar(--md-sys-color-surface)The table’s surface, and a row at rest.
--wm-data-table-container-shapevar(--md-sys-shape-corner-medium)The corners of the scrolling table.
--wm-data-table-outline-colorvar(--md-sys-color-outline-variant)The edge of the scrolling table.
--wm-data-table-header-height56pxThe header row’s height at density 0; each density step takes 4px off.
--wm-data-table-header-colorvar(--md-sys-color-surface-container)The header row’s surface.
--wm-data-table-header-text-colorvar(--md-sys-color-on-surface-variant)The column names.
--wm-data-table-row-height52pxA row’s least height at density 0; each density step takes 4px off.
--wm-data-table-row-text-colorvar(--md-sys-color-on-surface)A cell’s text.
--wm-data-table-row-hover-colorcolor-mix(in srgb, var(--md-sys-color-on-surface) 8%, var(--md-sys-color-surface))A hovered row’s surface, opaque so pinned cells cover what scrolls under.
--wm-data-table-row-pressed-colorcolor-mix(in srgb, var(--md-sys-color-on-surface) 10%, var(--md-sys-color-surface))A pressed row’s surface.
--wm-data-table-row-selected-colorvar(--md-sys-color-secondary-container)A selected row’s surface.
--wm-data-table-row-selected-hover-colorcolor-mix(in srgb, var(--md-sys-color-on-secondary-container) 8%, var(--md-sys-color-secondary-container))A selected row’s surface while hovered.
--wm-data-table-row-selected-text-colorvar(--md-sys-color-on-secondary-container)A selected row’s text.
--wm-data-table-divider-colorvar(--md-sys-color-outline-variant)The line between rows.
--wm-data-table-cell-padding16pxThe space at each side of a cell.
--wm-data-table-sort-icon-size18pxThe sort arrow’s size.
--wm-data-table-sort-icon-colorvar(--md-sys-color-on-surface)The sort arrow of a sorted column.
--wm-data-table-sort-icon-hover-opacity0.6The sort arrow of an unsorted column, as its header is hovered.
--wm-data-table-search-width20remThe search field’s width, once the table is 600px wide or more.
--wm-data-table-page-size-width9remThe rows-per-page choice’s width.
--wm-data-table-resizer-width2pxThe line that resizes a column.
--wm-data-table-resizer-colorvar(--md-sys-color-outline-variant)The resize line at rest.
--wm-data-table-resizer-active-colorvar(--md-sys-color-primary)The resize line while hovered or moving.
--wm-data-table-pin-shadow-colorcolor-mix(in srgb, var(--md-sys-color-shadow) 25%, transparent)The shadow a pinned column casts over what scrolls under it.
--wm-data-table-pin-shadow-size4pxThe size of that shadow.
--wm-data-table-bulk-bar-colorvar(--md-sys-color-secondary-container)The bar that replaces the toolbar while rows are selected.
--wm-data-table-bulk-bar-text-colorvar(--md-sys-color-on-secondary-container)That bar’s text.
--wm-data-table-bulk-bar-shapevar(--md-sys-shape-corner-medium)That bar’s corners.
--wm-data-table-toolbar-min-height64pxThe least height of the toolbar and bulk bar.
--wm-data-table-toolbar-gap12pxThe space between toolbar parts, and between the table’s sections.
--wm-data-table-state-durationvar(--md-sys-motion-spring-effects-fast-duration)How long a row’s surface takes to change.
--wm-data-table-state-easingvar(--md-sys-motion-spring-effects-fast-easing)The easing of that change.
--wm-data-table-bulk-bar-padding-inline16pxThe space at the bulk bar’s sides.
--wm-data-table-bulk-bar-padding-block8pxThe space above and below the bulk bar’s content.
--wm-data-table-chips-gap8pxThe space between filter chips and between bulk actions.
--wm-data-table-header-gap4pxThe space between a header’s label and its sort icon.
--wm-data-table-resizer-target-width16pxThe width a pointer can grab to resize a column.
--wm-data-table-resizer-inset12pxThe space above and below the resizer’s line.
--wm-data-table-control-cell-padding4pxThe space at the sides of a selection or actions cell.
--wm-data-table-skeleton-gap8pxThe space between loading rows.
--wm-data-table-skeleton-height32pxA loading row’s height.
--wm-data-table-state-padding32pxThe space above and below the empty and error states.
--wm-data-table-settings-gap8pxThe space between the parts of a column settings row.
--wm-data-table-settings-row-padding4pxThe space above and below a column settings row.
--wm-data-table-settings-icon-size18pxThe pinned icon’s size in column settings.
--wm-data-table-filter-gap16pxThe space between a filter dialog’s fields.
--wm-data-table-compact-figure-gap12pxThe space between a compact row’s figures, in a table with no other text column.
--wm-data-table-compact-value-weightvar(--md-sys-typescale-body-medium-emphasized-weight)A compact row’s figure: the body role’s emphasized weight, beside its column’s name.