Value Formatter

Format cell text for display — currency, dates, percentages — without changing the data.

Format display values

Set valueFormatter on a column. It formats for display only — the underlying data stays unchanged. For custom UI, use cellRenderer.

TypeScript
{
accessor: "salary",
label: "Salary",
type: "number",
valueFormatter: ({ value }) =>
typeof value === "number" ? `$${value.toLocaleString()}` : "",
}

Use other row fields

Read row when the display string needs more than the current cell.

TypeScript
{
accessor: "firstName",
label: "Name",
valueFormatter: ({ value, row }) => `${value} ${row.lastName ?? ""}`.trim(),
}

Copy and CSV

With a valueFormatter, copy and CSV use the formatted value by default. Set the flags to false for raw values, or use exportValueGetter for a CSV-only override.

TypeScript
{
accessor: "salary",
label: "Salary",
type: "number",
valueFormatter: ({ value }) =>
typeof value === "number" ? `$${value.toLocaleString()}` : "",
// useFormattedValueForClipboard: false, // copy raw number
// useFormattedValueForCSV: false, // export raw number
exportValueGetter: ({ value }) =>
typeof value === "number" ? value.toFixed(2) : "",
}

Example

Currency, dates, percentages, and combined fields. Use Code or StackBlitz for the full example.

Props

Value Formatter Configuration

PropertyRequiredDescriptionExample
Optional
Formats the cell for display without changing the underlying data. Returns a string, number, or array of those.
ColumnDef.useFormattedValueForClipboard
boolean
Optional
When a valueFormatter exists, defaults to true (formatted on copy). Set false to copy the raw value.
ColumnDef.useFormattedValueForCSV
boolean
Optional
When a valueFormatter exists, defaults to true (formatted in CSV). Set false for raw values. Ignored if exportValueGetter is set.
Optional
Custom CSV export value. Takes precedence over useFormattedValueForCSV.

Formatter arguments

ValueFormatterProps

PropertyRequiredDescriptionExample
accessor
Required
The column accessor/key for the cell being formatted
colIndex
number
Required
The column index (0-based)
row
Required
The complete row object containing all data for this row
rowIndex
number
Required
The row index (0-based)
Required
The raw cell value to be formatted