Custom styles

Style every part of DataTable via the customStyles prop, or apply per-row styles conditionally with conditionalRowStyles.

Custom styles

Toggle between conditional row styles (salary highlight + inactive fade) and a customStyles header override.

Mode:Yellow highlight = salary > $140k · Faded = inactive
Name
Department
Salary
Status
Aria Chen
Engineering
$155,000
Active
Marcus Webb
Product
$132,000
Active
Priya Kapoor
Design
$118,000
Inactive
Jordan Ellis
Analytics
$143,000
Active
Sam Rivera
Engineering
$128,000
Inactive
Taylor Brooks
Sales
$97,000
Active

customStyles: targeting table parts

The customStyles prop accepts a TableStyles object. Each key targets a specific part of DataTable and accepts a style property with standard React.CSSProperties values.

import DataTable, { type TableStyles } from 'react-data-table-component';

const customStyles: TableStyles = {
  headRow: {
    style: {
      backgroundColor: '#f0f4ff',
      fontWeight: 700,
    },
  },
  rows: {
    style: {
      fontSize: '14px',
    },
    selectedHighlightStyle: {
      backgroundColor: '#e0eaff',
    },
  },
  cells: {
    style: {
      paddingLeft: '16px',
      paddingRight: '16px',
    },
  },
};

<DataTable columns={columns} data={data} customStyles={customStyles} />

Available style targets

KeyDescription
tableThe root <div> wrapping the table
tableWrapperInner wrapper for overflow handling
responsiveWrapperHorizontal scroll container
headerTitle bar above the table
subHeaderSub-header area (search, actions)
headColumn header area
headRowColumn header row
headCellsColumn header cells
cellsBody cells
rowsBody rows (includes selectedHighlightStyle)
expanderRowExpanded row container
expanderCellExpander toggle cell
expanderButtonExpand/collapse button icon
paginationPagination bar
noDataEmpty-state container
progressLoading state container

Conditional row styles

Use conditionalRowStyles to apply styles to individual rows based on a predicate. Multiple entries can match the same row. They are applied in array order.

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

const conditionalRowStyles: ConditionalStyles<Employee>[] = [
  {
    when: row => row.salary > 100000,
    style: { backgroundColor: '#fff9e6' },
  },
  {
    when: row => !row.active,
    style: { opacity: 0.5 },
  },
  {
    // Use a CSS class instead of inline styles
    when: row => row.role === 'Admin',
    classNames: ['row-admin'],
  },
];

<DataTable
  columns={columns}
  data={data}
  conditionalRowStyles={conditionalRowStyles}
/>

CSS custom properties

For theming that affects the entire table, prefer CSS custom properties via createTheme() or by overriding variables directly. See the Themes page.

To replace pagination or expander icons, see the Icons page.

Migrating from v7

In v7, customStyles accepted CSSObject from styled-components. In v8, they accept React.CSSProperties. The practical difference: pseudo-selectors like &:hover are not valid here. Use conditionalRowStyles or CSS classes for hover and focus states.