Skip to content
Mendy UI

Table

Table API

Component props, controller options, and exported helpers.

On this page

All exports on this page come from @mendylanda/ui/table. Start with the overview for a runnable example.

DataTable

Use either rows, columns, and getRowId, or an existing table instance from useDataTable. DataTableProps<Row> expresses this choice.

PropDefaultPurpose
rowsRequired without tableReadonly array of records.
columnsRequired without tableTableColumn<Row>[].
getRowId(row, index)Required without tableStable record identity.
tableOptionalExisting DataTableInstance<Row>; owns state and processing.
toolbarStartNoneCustom controls beside the filter bar, before actions and column settings.
toolbarNoneApplication actions beside the filters or above the grid.
footerNoneContent below the grid, reserved by fill layout.
showColumnSettingstrueBuilt-in visibility, order, pinning, and sizing controls.
showPaginationfalse with an instanceShow pagination controls. The rows/columns form enables them for client pagination.
filtersNoneShared filter controller for the toolbar, resets, and empty-result recovery.
filterBarDefault barPresentation options passed to TableFilters; false hides the bar.

The rows/columns form also accepts the controller options below. Both forms accept the viewport props in the next section.

TableView and viewport props

TableView renders the grid around a required table instance, without the assembled toolbar or column settings. These props also work on DataTable.

PropDefaultPurpose
label"Data table"Accessible name for the grid. Use a dataset-specific name.
layout"content""content" fits rows; "fill" uses remaining viewport height.
minHeight240Minimum fill frame height in pixels, including toolbar and footer. Ignored in content layout.
height"auto"Number or CSS height in content layout. Fill layout takes precedence.
rowHeight44Fixed pixels or "auto" for measured rows.
status"ready""loading", "ready", or "error".
refreshingfalseReport a background refresh while keeping existing rows.
errorNoneError content for a failed query.
retryNoneCallback for initial error recovery.
loadMoreNone{ available, loading, load, error? } for incremental loading.
emptyStateAutomaticCustom empty content; replaces automatic recovery actions too.
loadingStateSkeleton rowsCustom initial loading content.
queryKeyDerived from observed stateAdditional result identity; keep stable when appending pages.
filtersNoneController for scroll/selection resets and empty-result recovery.
onRowClick(row)NoneSingle-click callback, also Enter's fallback action.
onRowActivate(row)NoneDouble-click and Enter callback.
isRowHighlighted(row)NoneApplication-owned row highlight.
rowSelectionControlstrueInline controls when row selection is enabled.
renderRowDetail(row)NoneExpanded content; return null for collapsed rows.
renderHeader(header)Standard headerCustom header content. Preserve sorting/accessibility when replacing it.
onCopyError(error)NoneReport a clipboard failure.
scrollRefNoneRef for the grid scroll element.
classNameNoneGrid container classes.
contentClassNameNoneClasses for application-owned cell content.
rowClassName(row)NonePer-record row classes.
footerNoneContent below the grid; included in fill-height calculation.

useDataTable

const table = useDataTable({ rows, columns, getRowId: (row) => row.id });

getRowLabel: (row) => string customizes the record description used by selection checkboxes. It defaults to the first visible value column, then the row number.

UseDataTableOptions<Row> extends the engine's table options, replacing its data and processing configuration with the fields below. Controlled state and change callbacks are forwarded to the engine.

OptionDefaultPurpose
processing.filtering"client""external" when supplied rows are already filtered.
processing.sorting"client""external" when the server owns order.
processing.pagination"off""client" or "external" for page-based tables.
stateInternal stateControlled sorting, pagination, row selection, and column state.
initialStateColumn defaultsInitial state for uncontrolled values.
onSortingChange, onPaginationChange, onRowSelectionChangeInternal updatesPair callbacks with the corresponding controlled state.
rowCountLoaded dataTotal records for external pagination.
enableCellSelectiontrueCell selection and keyboard copying.
enableRowSelectionInferredEnabled by a row-selection callback or a selection column; otherwise opt in.
enableColumnPinningtrueAllow sticky columns.
columnResizeMode"onChange"Update sizing as a handle moves.
defaultColumn180px; min 48; max 1200Shared engine column defaults.
preferencesNone{ key, scope, storage?, onError? }.

See data and queries for controlled query integration. State callbacks can receive updater functions; use state setters that support both a value and an updater.

Column builders and formatters

ExportSignature / purpose
defineColumns<Row>(build)Returns TableColumn<Row>[]; provides accessor, computed, and display.
column.accessor(path, options)Typed property path with required label.
column.computed(id, accessor, options)Computed value with a stable ID and required label.
column.display(id, options)Non-data content with label and render(row).
format.currency(currency, locale?)Number display/text formatter, aligned to the end.
format.number(options?, locale?)Number display/text formatter, aligned to the end.
format.date(options?, locale?)Date display/text formatter.
ValueFormat<Value>{ display, text, align? } for custom formatting.

Columns and rendering documents sizing, custom callbacks, null values, and existing column definitions.

Composed controls

ComponentRequired propsOther props / behavior
TableFiltersfiltersFilter bar presentation props; use the same controller on TableView.
TableColumnSettingstableVisibility, reordering, pinning, and reset controls.
TablePaginationtableloading disables controls during requests.
TableActionBarcount, onClear, childrenRenders only when count is nonzero.
selectionColumn<Row>()NoneDedicated checkbox column when inline controls are unsuitable.

These components share the same table or filter controller; creating a second controller would create separate state.

Preferences and saved views

ExportPurpose
captureTablePreferences(table)Capture versioned order, pinning, sizing, and visibility.
applyTablePreferences(table, input)Reconcile and apply stored preferences.
TableSavedViewsControls with views, onApply, onSave, and optional onDelete.
SavedTableView<Filters>View ID, name, filters, sorting, and preferences.
PreferenceStorageStorage adapter with read(key) and write(key, value).
TablePreferencesVersioned column preference value.

Selection and export

useResultSelection({ scope: { key, value }, rowIds, totalCount }) manages explicit record IDs or all matching results. Connect its rowSelection and onRowSelectionChange to useDataTable. See selection for scope semantics.

selectedCellsText(table) returns selected cell text in a tab-separated layout. tableCsv(table, { selectedOnly? }) returns CSV for loaded records. Neither function fetches remote results or performs a backend operation.