gridcn2.0.0
Components and props

Labels

Look up every string in DataGridLabels, grouped by the surface that owns it, and the rules that merge a labels override.

DataGridLabels holds the user-facing strings of the core and most add-ons, grouped by the surface that owns it. DEFAULT_LABELS holds the English defaults. The labels prop of DataGrid and DataGridProvider takes a DeepPartialLabels object that overrides some of them. The Labels and i18n guide shows how to wire a translation library and flip the layout to right to left.

GroupSurface
toolbarQuick search, filter menu, header filter, columns menu
sortSort list
filterOperatorsOperator names in the filter menu
contextMenuCell and header context menu, header dropdown
keybindingsKeybindings dialog
markersRow marker column
gridCore grid messages: messages for empty, busy, and failed states, the date editor, and screen reader announcements
ioExport menu, import dialog, print button
paginationPager
statusBarStatus bar
viewsSaved views menu
findReplaceFind and replace panel

The default labels format every number with the locale prop, such as the counts in the status bar. A label that you override formats its own numbers.

DataGridLabels does not hold the labels of a lookup column. A lookup column takes options.labels (lookup cell). The comments popover takes labels.comments of the grid and labels on useDataGridComments.

A label is a string or a function. A function label receives the values that its text needs, such as a count or a page number, and returns the string. The type of each field names its arguments:

import {
  DataGrid,
  type DeepPartialLabels,
} from "@/components/data-grid/data-grid";

const labels: DeepPartialLabels = {
  grid: { emptyState: "Keine Zeilen" },
  toolbar: { searchMatches: (current, total) => `${current} von ${total}` },
};

export function EmptyGrid() {
  return (
    <DataGrid className="h-80" defaultData={[]} columns={[]} labels={labels} />
  );
}

The empty grid shows "Keine Zeilen". With the toolbar add-on, its search shows "3 von 17" for the third of 17 matches. Every other string stays English.

Override rules

  • Plain objects merge key by key, at every depth.
  • A string, a function, or an array that you set replaces the default as a whole.
  • The grid compares labels by content, so a literal object of strings needs no useMemo. A label that is a function counts as changed when its identity changes.
  • A key that you set to undefined keeps the default. To blank a string label, set it to "".
  • A component with its own labels prop merges three layers: the default, then the labels.<group> of the grid, then the labels prop of the component. These components are DataGridPaginationBar, DataGridStatusBar, and DataGridViews.
  • useDataGridLabels() returns the merged result under the provider.

DataGridLabels

Each group below is one key of DataGridLabels.

toolbar

Prop

Type

sort

Prop

Type

filterOperators

Prop

Type

contextMenu

moveTowardStart and moveTowardEnd name the header menu items that move a column. widenColumn and narrowColumn name the items that change its width by 16 px.

Prop

Type

keybindings

In the keybindings dialog, a custom command shows its label. Without label and without an entry in keybindings.actions, the dialog shows the action name as words: exportCsv shows as "Export csv". keybindings.actions.openKeybindings names the action that opens the dialog.

Prop

Type

markers

Prop

Type

grid

Prop

Type

io

Prop

Type

pagination

Prop

Type

statusBar

Prop

Type

views

Prop

Type

findReplace

Prop

Type

On this page