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.
| Group | Surface |
|---|---|
toolbar | Quick search, filter menu, header filter, columns menu |
sort | Sort list |
filterOperators | Operator names in the filter menu |
contextMenu | Cell and header context menu, header dropdown |
keybindings | Keybindings dialog |
markers | Row marker column |
grid | Core grid messages: messages for empty, busy, and failed states, the date editor, and screen reader announcements |
io | Export menu, import dialog, print button |
pagination | Pager |
statusBar | Status bar |
views | Saved views menu |
findReplace | Find 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
labelsby content, so a literal object of strings needs nouseMemo. A label that is a function counts as changed when its identity changes. - A key that you set to
undefinedkeeps the default. To blank a string label, set it to"". - A component with its own
labelsprop merges three layers: the default, then thelabels.<group>of the grid, then thelabelsprop of the component. These components areDataGridPaginationBar,DataGridStatusBar, andDataGridViews. 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