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

Each key takes a style object. Some keys accept extra style fields for a specific state.

KeyExtra fieldsDescription
table-The table root element.
tableWrapper-Wrapper <div> around the table.
responsiveWrapper-Scroll container around the table.
headerfontColor, fontSizeTitle and actions bar above the table.
subHeader-Sub-header bar (search, actions).
head-Column header area.
headRowdenseStyleColumn header row.
headCellsdraggingStyleColumn header cells.
cellsdraggingStyleBody cells.
rowsselectedHighlightStyle, denseStyle, highlightOnHoverStyle, stripedStyleBody rows.
expanderRow-The expanded content row.
expanderCell-Cell containing the expand/collapse button.
expanderButton-The expand/collapse button.
paginationpageButtonsStylePagination bar and page buttons.
footer-The footer row container.
footerCells-Individual footer cells.
noData-Empty-state container.
progress-Loading indicator 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