API reference
Complete reference for every prop, type, and export in react-data-table-component v8.
Looking for examples or recipes? This page is the flat reference for “what does prop X do?”. Each feature has its own page with examples. Start there if you’re new:
DataTable props
DataTable<T> accepts the following props where T is the row data type. Only columns and data are required.
Data
Prop Type Default Description dataT[]- Required. Array of row objects.columnsTableColumn<T>[]- Required. Column definitions.keyFieldstring"id"Property on each row used as a stable React key. progressPendingbooleanfalseShow a loading state. On initial load (no data yet) renders shimmer skeleton rows. On re-fetch (data already loaded) dims the existing rows and overlays a centered spinner. The column header always stays visible. progressComponentReactNodebuilt-in spinner Custom loading indicator. noDataComponentReactNodebuilt-in message Rendered when data is empty.
Layout & appearance
Prop Type Default Description titlestring | ReactNode- Table title shown in the header bar. actionsReactNode | ReactNode[]- Content rendered on the right side of the header bar. subHeaderReactNode- Content for the sub-header bar. Providing any value shows the bar. subHeaderAlignAlignment"right"Alignment of sub-header content. subHeaderWrapbooleantrueAllow sub-header to wrap onto multiple lines. noHeaderbooleanfalseHide the title/actions header bar entirely. noTableHeadbooleanfalseHide the column header row. persistTableHeadbooleanfalseShow the column header even when data is empty. The header always stays visible during progressPending regardless of this prop. densebooleanfalseReduce row height for a compact look. responsivebooleantrueWrap the table in a horizontally scrollable container. fixedHeaderbooleanfalseStick the column header at the top when scrolling. fixedHeaderScrollHeightstring"100vh"Max height of the scrollable body when fixedHeader is on. directionDirection"ltr"Text direction (ltr, rtl, auto). classNamestring- Extra CSS class on the root element. styleCSSProperties- Inline styles on the root element. ariaLabelstring- Value for the table’s aria-label. disabledbooleanfalseDisable all interactive controls.
Theming & styling
Prop Type Default Description themestring"default"Named theme registered with createTheme(). customStylesTableStyles- Fine-grained style overrides. See TableStyles . conditionalRowStylesConditionalStyles<T>[]- Apply styles or class names to rows when a predicate matches. stripedbooleanfalseAlternate row background colors. highlightOnHoverbooleanfalseHighlight rows on mouse-over. pointerOnHoverbooleanfalseShow a pointer cursor on row hover. columnSeparatorboolean | "subtle" | "full"- Vertical lines between body columns. true/"subtle" = inset 60%-height line, "full" = full-height line. headerSeparatorboolean | "subtle" | "full"trueVertical lines between header cells. true/"subtle" = inset line (default), "full" = full-height, false = none. animateRowsbooleanfalseStaggered entrance and sort animations. Respects prefers-reduced-motion.
Sorting
Prop Type Default Description defaultSortFieldIdstring | number- Column id to sort by on initial render. defaultSortAscbooleantrueInitial sort direction. sortServerbooleanfalseDisable client-side sorting; fire onSort and let the server sort. sortFunctionSortFunction<T> | null- Global custom sort function applied to all sortable columns. sortIconReactNodebuilt-in chevron Custom sort direction indicator. onSort(column, direction, sortedRows) => void- Called whenever the sort column or direction changes.
Prop Type Default Description paginationbooleanfalseEnable built-in pagination controls. paginationPerPagenumber10Rows shown per page. paginationRowsPerPageOptionsnumber[][10,15,20,25,30]Options in the rows-per-page dropdown. paginationDefaultPagenumber1Initial active page. paginationResetDefaultPagebooleanfalseToggle to reset to page 1 (e.g. after a filter change). paginationTotalRowsnumber- Total row count for server-side pagination. paginationServerbooleanfalseDelegate page changes to onChangePage / onChangeRowsPerPage. paginationServerOptionsPaginationServerOptions- Selection-persistence options for server-side mode. paginationComponentOptionsPaginationOptions- Localisation and display options for the built-in paginator. paginationComponentReact.ComponentType- Replace the built-in pagination UI entirely. paginationIconsPaginationIcons- Override any or all pagination icons. Pass a partial object: { next: <MyIcon /> }. onChangePage(page, totalRows) => void- Called when the active page changes. onChangeRowsPerPage(rowsPerPage, page) => void- Called when rows-per-page selection changes.
Row selection
Prop Type Default Description selectableRowsbooleanfalseShow a checkbox column for row selection. selectableRowsSinglebooleanfalseAllow only one row to be selected at a time. selectableRowsNoSelectAllbooleanfalseHide the “select all” checkbox in the header. selectableRowsVisibleOnlybooleanfalse”Select all” only selects rows on the current page. selectableRowsHighlightbooleanfalseHighlight selected rows using the theme’s selected color. selectableRowDisabled(row: T) => boolean- Disable selection for a specific row. selectableRowSelected(row: T) => boolean- Pre-select rows that satisfy the predicate. selectableRowsComponent"input" | ReactNodebuilt-in checkbox Custom checkbox component. selectableRowsComponentPropsobject- Extra props forwarded to the custom checkbox component. onSelectedRowsChange(state) => void- Called whenever selection changes. Receives { allSelected, selectedCount, selectedRows }. clearSelectedRowsboolean- Deprecated. Toggle to clear selection. Use ref.current.clearSelectedRows() instead.
Expandable rows
Prop Type Default Description expandableRowsbooleanfalseEnable the expandable row feature. expandableRowsComponentReact.ComponentType- Component rendered in the expanded panel. Receives { data: T }. expandableRowsComponentPropsobject- Extra props merged into expandableRowsComponent. expandableRowExpanded(row: T) => boolean- Control which rows start expanded. expandableRowDisabled(row: T) => boolean- Prevent specific rows from being expanded. expandableRowsHideExpanderbooleanfalseHide the expander chevron column (use with expandOnRowClicked). expandOnRowClickedbooleanfalseToggle expansion by clicking anywhere on the row. expandOnRowDoubleClickedbooleanfalseToggle expansion by double-clicking anywhere on the row. expandableInheritConditionalStylesbooleanfalseApply the parent row’s conditional styles to the expanded panel. expandableIcon{ collapsed, expanded }built-in chevron Custom expand/collapse icons. onRowExpandToggled(expanded, row) => void- Called when a row is expanded or collapsed.
Row events
Prop Type Description onRowClicked(row, event) => voidCalled when a row is left-clicked. onRowDoubleClicked(row, event) => voidCalled when a row is double-clicked. onRowMiddleClicked(row, event) => voidCalled when a row is middle-clicked (scroll-click). Use with onRowClicked to implement open-in-new-tab behaviour. onRowMouseEnter(row, event) => voidCalled when the pointer enters a row. onRowMouseLeave(row, event) => voidCalled when the pointer leaves a row.
Column features
Prop Type Default Description resizablebooleanfalseShow drag handles on column headers for resizing. columnGroupsColumnGroup[]- Spanning group headers rendered above the column header row. filterValuesRecord<string | number, FilterState>- Controlled filter state. Omit to use internal state. See Filtering . onFilterChange(columnId, filter: FilterState) => void- Called when the user clicks Apply or Clear in a filter popup. onColumnOrderChange(columns: TableColumn<T>[]) => void- Called after a drag-to-reorder column operation with the new column order. onColumnGroupOrderChange(groups: ColumnGroup[], columns: TableColumn<T>[]) => void- Called after a group drag-reorder with the new group order and the matching updated column order.
ColumnGroup
Defines a spanning group header above one or more columns. Pass an array to the columnGroups prop.
import { type ColumnGroup } from 'react-data-table-component' ;
const columnGroups : ColumnGroup [] = [
{ name: 'Employee' , columnIds: [ 'first' , 'last' , 'dept' ] },
{ name: 'Compensation' , columnIds: [ 'base' , 'bonus' ], align: 'left' },
];
Field Type Default Description nameReactNode- Required. Group header label. Accepts JSX.columnIds(string | number)[]- Required. Ids of columns under this group. Must match each column’s id exactly.align'left' | 'center' | 'right''center'Horizontal alignment of the group label. reorderboolean- Allow drag-to-reorder for this group. Dragging moves all member columns as a block. Fires onColumnGroupOrderChange.
Columns not listed in any group span the full group-row height with no label.
TableColumn<T>
import { type TableColumn } from 'react-data-table-component' ;
const columns : TableColumn < MyRow >[] = [
{
id: 'name' ,
name: 'Full name' ,
selector : row => row.name,
sortable: true ,
width: '200px' ,
},
];
Prop Type Description idstring | numberStable identity used by defaultSortFieldId, columnGroups, and filterValues. nameReactNodeColumn header label. selector(row, index?) => Primitive | ReactNodeData accessor. For sortable columns return a Primitive (string | number | boolean). cell(row, index, column, id) => ReactNodeCustom cell renderer. Overrides the selector display value. format(row, index) => ReactNodeFormat the selector value for display without changing the sort key. sortablebooleanEnable sorting on this column. sortFunction(a: T, b: T) => numberCustom comparator for this column. sortFieldstringField key passed to onSort for server-side sort identification. filterablebooleanShow a filter popup for this column. filterType"text" | "number" | "date"Filter operator set and input widget. Defaults to "text". See Filtering . filterFunction(row, filter: FilterState) => booleanCustom filter predicate. Overrides built-in operator logic. Receives the full FilterState including both conditions. widthstringFixed column width, e.g. "120px". minWidthstringMinimum width. maxWidthstringMaximum width. grownumberFlex-grow factor (default 1). Set to 0 to prevent growing. rightbooleanRight-align cell content. centerbooleanCenter cell content. wrapbooleanAllow cell text to wrap. compactbooleanRemove cell padding. buttonbooleanCenter content and suppress row click propagation. allowOverflowbooleanAllow cell content to overflow (useful for dropdowns and popovers). ignoreRowClickbooleanPrevent clicks in this cell from firing onRowClicked. hideMedia | numberHide the column below the given breakpoint (Media.SM = 599px, MD = 959px, LG = 1280px) or a custom pixel value. omitbooleanExclude the column entirely. Toggle this to show/hide a column. reorderbooleanAllow drag-to-reorder for this column (requires reorder on at least two columns). styleCSSPropertiesInline styles applied to every cell in this column. conditionalCellStylesConditionalStyles<T>[]Per-cell conditional styles.
Inline editing
Prop Type Description editablebooleanShorthand for editor: { type: 'text' }. Ignored when editor is also set. editorCellEditorEditor configuration. See CellEditor below. Takes precedence over editable. onCellEditCellEditCallback<T>Called when the user commits an edit. Receives (row: T, value: string, column: TableColumn<T>). The value is always a string; parse it to the target type in your handler.
See Inline editing for examples, CSS variables, and styling guidance.
CellEditor
import { type CellEditor } from 'react-data-table-component' ;
type CellEditor =
| { type : 'text' ; placeholder ?: string }
| {
type : 'select' ;
options : Array <{ value : string ; label : React . ReactNode }>;
placeholder ?: string ;
};
Variant Field Type Description Both type"text" | "select"Editor widget to render. Both placeholderstringPlaceholder text. For select, shown as a disabled hidden option when the current value is empty. selectoptions{ value: string; label: ReactNode }[]Dropdown options. The value is what gets committed; label is displayed (must be string or number inside native <option>).
Inline editing CSS classes
Class Applied to Purpose rdt_cellEditableCell container Added on every cell that has an editor defined (idle state). rdt_cellEditingCell container Added while the editor is open. Removes padding and paints the focus ring. rdt_editInput<input>Text editor control inside an editing cell. rdt_editSelect<select>Dropdown editor control inside an editing cell.
Inline editing CSS variables
Variable Default Purpose --rdt-color-cell-edit-bg8% primary on bg Background of the cell while editing. --rdt-color-cell-edit-hover6% primary Background of an editable cell on hover. --rdt-color-cell-edit-hover-border40% primary Dashed underline colour on editable cell hover.
DataTableHandle (ref)
Attach a ref to DataTable to imperatively control it.
import DataTable, { type DataTableHandle } from 'react-data-table-component' ;
import { useRef } from 'react' ;
function App () {
const ref = useRef < DataTableHandle >( null );
return (
<>
< button onClick = {() => ref.current?. clearSelectedRows ()}>
Clear selection
</ button >
< DataTable ref = {ref} columns = {columns} data = {data} selectableRows />
</>
);
}
Method Description clearSelectedRows()Deselect all currently selected rows.
TableStyles
Pass to customStyles to override styles for any part of DataTable. Each key accepts a style object (React.CSSProperties) and optional extra properties.
import DataTable, { type TableStyles } from 'react-data-table-component' ;
const customStyles : TableStyles = {
headRow: {
style: {
backgroundColor: '#f8fafc' ,
borderBottomWidth: '2px' ,
},
},
headCells: {
style: {
fontSize: '13px' ,
fontWeight: 700 ,
color: '#374151' ,
},
},
rows: {
style: { minHeight: '56px' },
highlightOnHoverStyle: {
backgroundColor: '#f0f9ff' ,
borderBottomColor: '#e0f2fe' ,
outline: '1px solid #bae6fd' ,
},
},
};
Key Extra fields Description table- The outermost table element. tableWrapper- Wrapper <div> around the table. responsiveWrapper- Horizontal-scroll wrapper (only present when responsive). headerfontColor, fontSizeTitle / actions bar at the top. subHeader- Sub-header bar. head- The <thead> element. headRowdenseStyleColumn header row. headCellsdraggingStyleIndividual 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 itself. paginationpageButtonsStylePagination bar and page buttons. noData- Empty-state container. progress- Loading indicator container.
ConditionalStyles<T>
Used with conditionalRowStyles and conditionalCellStyles to apply styles or class names based on row data.
const conditionalRowStyles = [
{
when : row => row.status === 'active' ,
style: { backgroundColor: '#f0fdf4' , color: '#166534' },
},
{
when : row => row.salary > 100000 ,
// style can also be a function:
style : row => ({ fontWeight: row.salary > 150000 ? 700 : 400 }),
},
{
when : row => row.flagged,
classNames: [ 'flagged-row' ],
},
];
Field Type Description when(row: T) => booleanRequired. Predicate that applies styles when this returns true.styleCSSProperties | ((row: T) => CSSProperties)Inline styles to apply. classNamesstring[]CSS class names to add.
createTheme()
Registers a custom named theme. Call this outside your component tree so it runs once.
import { createTheme } from 'react-data-table-component' ;
createTheme (
'brand' , // name (pass to the theme prop)
{
text: { primary: '#1a1a2e' , secondary: '#4a4a6a' , disabled: 'rgba(26,26,46,.38)' },
background: { default: '#f0f4ff' },
divider: { default: '#dde3f0' },
button: { default: '#6366f1' , hover: '#4f46e5' , focus: 'rgba(99,102,241,.25)' , disabled: '#c7d2fe' },
selected: { default: '#ede9fe' , text: '#3730a3' },
highlightOnHover: { default: '#e0e7ff' , text: '#1a1a2e' },
striped: { default: '#f5f3ff' , text: '#1a1a2e' },
},
'default' , // optional: inherit from this theme
);
Parameter Type Description namestringTheme name to reference in the theme prop. overridesPartial<Theme>Token overrides. Only the keys you provide are changed. inheritstringOptional name of a built-in or previously registered theme to inherit from.
The Theme interface token keys:
Token Fields textprimary, secondary, disabledbackgrounddefaultcontextbackground, textdividerdefaultbuttondefault, hover, focus, disabledselecteddefault, texthighlightOnHoverdefault, textstripeddefault, textcolorScheme"light" | "dark". Sets native form control rendering.
Passed to paginationComponentOptions.
Field Type Default Description rowsPerPageTextstring"Rows per page:"Label for the rows-per-page select. rangeSeparatorTextstring"of"Separator between current range and total, e.g. “1–10 of 50”. noRowsPerPagebooleanfalseHide the rows-per-page selector. selectAllRowsItembooleanfalseAdd an “All” option to the rows-per-page selector. selectAllRowsItemTextstring"All"Label for the “All” option.
Passed to paginationServerOptions when using server-side pagination.
Field Type Default Description persistSelectedOnPageChangebooleanfalseKeep the current selection when the page changes. persistSelectedOnSortbooleanfalseKeep the current selection when the sort column or direction changes.
The props your custom paginationComponent will receive.
Field Type Description rowsPerPagenumberCurrently selected rows-per-page value. rowCountnumberTotal row count. currentPagenumberCurrent active page (1-based). onChangePage(page, totalRows) => voidCall this to change page. onChangeRowsPerPage(rowsPerPage, page) => voidCall this to change rows-per-page.
Enums & constants
All enums and constants are re-exported from the package root.
import { Media, Direction, Alignment, SortOrder } from 'react-data-table-component' ;
Enum Values Description MediaSM = "sm" (≤ 599px), MD = "md" (≤ 959px), LG = "lg" (≤ 1280px)Breakpoints for the column hide prop. DirectionLTR = "ltr", RTL = "rtl", AUTO = "auto"Text direction for the direction prop. AlignmentLEFT = "left", RIGHT = "right", CENTER = "center"Alignment for subHeaderAlign. SortOrderASC = "asc", DESC = "desc"Sort direction passed to onSort and sortFunction.
useColumnVisibility
Hook for managing column show/hide state outside of DataTable. Pairs with the omit column prop.
import { useColumnVisibility, type TableColumn } from 'react-data-table-component' ;
const rawColumns : TableColumn < Row >[] = [
{ id: 'name' , name: 'Name' , selector : r => r.name },
{ id: 'dept' , name: 'Department' , selector : r => r.dept },
];
function App () {
const { columns , visibility , toggle , setAll } = useColumnVisibility (rawColumns);
return (
<>
{visibility. map (({ id , name , visible }) => (
< label key = {id}>
< input type = "checkbox" checked = {visible} onChange = {() => toggle (id)} />
{name}
</ label >
))}
< button onClick = {() => setAll ( true )}>Show all</ button >
< DataTable columns = {columns} data = {data} />
</>
);
}
UseColumnVisibilityResult
Field Type Description columnsTableColumn<T>[]Columns with omit set according to current visibility. Pass directly to DataTable. visibilityColumnVisibilityEntry[]Current visibility state for every column. toggle(id: string | number) => voidToggle the visibility of a single column by id. setAll(visible: boolean) => voidShow or hide all columns at once.
ColumnVisibilityEntry
Field Type Description idstring | numberColumn id. nameReactNodeColumn name (mirrors the name field from the column definition). visiblebooleanWhether the column is currently visible.
Package exports
// Default export
import DataTable from 'react-data-table-component' ;
// Named exports
import {
createTheme,
defaultThemes,
Media,
Direction,
Alignment,
SortOrder,
// Default icon sets (useful when building custom pagination/expander UIs)
DEFAULT_PAGINATION_ICONS,
DEFAULT_EXPANDABLE_ICON,
// Headless hooks
useTableState,
useColumns,
useTableData,
useColumnFilter,
useColumnVisibility,
// Filter utilities
emptyFilterState,
isFilterActive,
} from 'react-data-table-component' ;
// TypeScript types
import type {
TableProps,
TableColumn,
ColumnGroup,
TableRow,
TableStyles,
Theme,
ThemeProp,
ConditionalStyles,
DataTableHandle,
ExpanderComponentProps,
PaginationComponentProps,
PaginationOptions,
PaginationServerOptions,
PaginationIcons,
SortFunction,
Selector,
// Column visibility hook types
UseColumnVisibilityResult,
ColumnVisibilityEntry,
// Filter types
FilterType,
FilterOperator,
FilterCondition,
FilterState,
} from 'react-data-table-component' ; Next Getting started →