Columns

Columns are defined as an array of TableColumn<T> objects. Each column controls its header label, data accessor, sort behaviour, rendering, and layout.

Column features

Toggle column visibility with omit, enable per-column filtering, and see custom cell renderers and conditional cell styles in action.

Columns:|Name column:
Name
Department
Salary
Status
Start date
Alex Kim
Engineering
$162,000
Active
Jun 5, 2017
Aria Chen
Engineering
$155,000
Active
Mar 12, 2019
Casey Morgan
HR
$88,000
Active
Sep 14, 2023
Jordan Ellis
Analytics
$143,000
Contractor
Nov 30, 2018
Marcus Webb
Product
$132,000
Remote
Jul 1, 2020
Priya Kapoor
Design
$118,000
Active
Jan 15, 2021
Sam Rivera
Engineering
$128,000
On Leave
Apr 22, 2022
Taylor Brooks
Sales
$97,000
Remote
Feb 8, 2023

Basic column definition

import { type TableColumn } from 'react-data-table-component';

interface Row {
  id: number;
  name: string;
  salary: number;
}

const columns: TableColumn<Row>[] = [
  {
    name: 'Name',
    selector: row => row.name,
    sortable: true,
  },
  {
    name: 'Salary',
    selector: row => row.salary,
    format: row => `$${row.salary.toLocaleString()}`,
    right: true,
  },
];

Column properties

PropTypeDescription
nameReactNodeHeader label
selector(row: T) => PrimitiveData accessor used for sorting and default display
cell(row, index, column, id) => ReactNodeCustom cell renderer. Overrides selector display
format(row, index) => ReactNodeFormat the selector value without replacing the sort key
sortablebooleanEnable sorting on this column
sortFunction(a, b) => numberCustom comparator for this column
sortFieldstringKey to pass to onSort for server-side sorting
filterablebooleanShow a filter input in the column header
filterFunction(row, value) => booleanCustom filter predicate (defaults to case-insensitive substring)
idstring | numberStable identity used by defaultSortFieldId and column groups
widthstringFixed width, e.g. "120px"
minWidthstringMinimum width
maxWidthstringMaximum width
grownumberFlex-grow factor (default 1)
rightbooleanRight-align cell content
centerbooleanCenter cell content
wrapbooleanAllow text to wrap
compactbooleanRemove cell padding
buttonbooleanCenter content and suppress row click propagation
allowOverflowbooleanAllow content to overflow the cell (for dropdowns/popovers)
ignoreRowClickbooleanPrevent cell clicks from triggering onRowClicked
hidenumber | "sm" | "md" | "lg"Hide the column below this breakpoint
omitbooleanExclude column entirely (useful for toggling visibility)
reorderbooleanAllow drag-to-reorder for this column
styleCSSPropertiesInline styles applied to every cell in this column
conditionalCellStylesConditionalStyles<T>[]Per-cell conditional styles

Custom cell renderer

{
  name: 'Actions',
  button: true,
  cell: row => (
    <button onClick={() => handleDelete(row.id)}>Delete</button>
  ),
}

Column filtering

Add filterable: true to any column to render a filter icon in the header. Clicking the icon opens a text input; rows are filtered client-side by default.

{ name: 'Name', selector: r => r.name, filterable: true }

// Custom filter logic:
{
  name: 'Status',
  selector: r => r.status,
  filterable: true,
  filterFunction: (row, value) => row.status.startsWith(value),
}

For controlled filter state, pass filterValues and onFilterChange to DataTable.

Column reordering

Mark columns with reorder: true and pass onColumnOrderChange to DataTable to enable drag-to-reorder handles. The callback receives the new column array in order.

const [cols, setCols] = React.useState(columns);

<DataTable
  columns={cols}
  data={data}
  onColumnOrderChange={setCols}
/>

Hiding columns

Toggle a column's visibility by setting omit dynamically:

const [showSalary, setShowSalary] = React.useState(true);

const columns = [
  { name: 'Name', selector: r => r.name },
  { name: 'Salary', selector: r => r.salary, omit: !showSalary },
];