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.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 Icons on the Themes 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.

Prop reference

PropTypeDefaultDescription
customStylesTableStyles-Fine-grained style overrides. See Custom styles.
conditionalRowStylesConditionalStyles<T>[]-Apply styles or class names to rows when a predicate matches.

customStyles takes a TableStyles object. See the API reference for every styleable slot.