Fixed header

Set fixedHeader to keep the column headers visible while the user scrolls through a long dataset. The table body becomes independently scrollable within a container whose height is controlled by fixedHeaderScrollHeight.

Fixed header

40 rows and ~1160px of columns. By default wide content scrolls horizontally inside the table. Turn fixedHeader off to unlock the disable-responsive checkbox: with both off, the table overflows the demo card instead of scrolling. While fixedHeader is on the checkbox is disabled, since fixedHeader always creates a scroll container.

fixedHeaderScrollHeight:
#
Name
Department
Salary
Status
Email
Location
1
Aria Chen
Engineering
$80,000
Active
New York, NY
2
Marcus Webb
Product
$81,237
Remote
Austin, TX
3
Priya Kapoor
Design
$82,474
On Leave
Portland, OR
4
Jordan Ellis
Analytics
$83,711
Contractor
Chicago, IL
5
Sam Rivera
Sales
$84,948
Active
Remote (EU)
6
Taylor Brooks
HR
$86,185
Remote
New York, NY
7
Casey Morgan
Engineering
$87,422
On Leave
Austin, TX
8
Alex Kim
Product
$88,659
Contractor
Portland, OR
9
Morgan Lee
Design
$89,896
Active
Chicago, IL
10
Drew Park
Analytics
$91,133
Remote
Remote (EU)
11
Aria Chen 2
Sales
$92,370
On Leave
New York, NY
12
Marcus Webb 2
HR
$93,607
Contractor
Austin, TX
13
Priya Kapoor 2
Engineering
$94,844
Active
Portland, OR
14
Jordan Ellis 2
Product
$96,081
Remote
Chicago, IL
15
Sam Rivera 2
Design
$97,318
On Leave
Remote (EU)
16
Taylor Brooks 2
Analytics
$98,555
Contractor
New York, NY
17
Casey Morgan 2
Sales
$99,792
Active
Austin, TX
18
Alex Kim 2
HR
$101,029
Remote
Portland, OR
19
Morgan Lee 2
Engineering
$102,266
On Leave
Chicago, IL
20
Drew Park 2
Product
$103,503
Contractor
Remote (EU)
21
Aria Chen 3
Design
$104,740
Active
New York, NY
22
Marcus Webb 3
Analytics
$105,977
Remote
Austin, TX
23
Priya Kapoor 3
Sales
$107,214
On Leave
Portland, OR
24
Jordan Ellis 3
HR
$108,451
Contractor
Chicago, IL
25
Sam Rivera 3
Engineering
$109,688
Active
Remote (EU)
26
Taylor Brooks 3
Product
$110,925
Remote
New York, NY
27
Casey Morgan 3
Design
$112,162
On Leave
Austin, TX
28
Alex Kim 3
Analytics
$113,399
Contractor
Portland, OR
29
Morgan Lee 3
Sales
$114,636
Active
Chicago, IL
30
Drew Park 3
HR
$115,873
Remote
Remote (EU)
31
Aria Chen 4
Engineering
$117,110
On Leave
New York, NY
32
Marcus Webb 4
Product
$118,347
Contractor
Austin, TX
33
Priya Kapoor 4
Design
$119,584
Active
Portland, OR
34
Jordan Ellis 4
Analytics
$120,821
Remote
Chicago, IL
35
Sam Rivera 4
Sales
$122,058
On Leave
Remote (EU)
36
Taylor Brooks 4
HR
$123,295
Contractor
New York, NY
37
Casey Morgan 4
Engineering
$124,532
Active
Austin, TX
38
Alex Kim 4
Product
$125,769
Remote
Portland, OR
39
Morgan Lee 4
Design
$127,006
On Leave
Chicago, IL
40
Drew Park 4
Analytics
$128,243
Contractor
Remote (EU)

How it works

When fixedHeader is enabled, the responsive wrapper gainsoverflow-y: auto and the max-height you set viafixedHeaderScrollHeight. The column header row getsposition: sticky; top: 0 so it remains in view as the body scrolls within that container.

Because the scroll container is the responsive wrapper, horizontal scrolling for wide tables continues to work normally. Both axes scroll together, but the header sticks on the vertical axis.

Turning the scroll container off

responsive={false} removes the table's own horizontal scroll container, letting wide content overflow into the parent instead. It exists for a few specific situations:

  • Parent-owned scrolling. The table sits inside your own scroll container (a dashboard panel, a split view, several tables sharing one horizontal scrollbar). Nesting the table's overflow-x: auto inside yours would produce scrollbars within scrollbars.
  • Print and PDF export. An overflow container clips everything past the fold; disabling it lets the full table width render in print stylesheets.
  • Table dictates layout. You want the page itself to widen or scroll rather than the table.
<div className="my-own-scroll-container">
  <DataTable columns={columns} data={data} responsive={false} />
  <OtherWidgetSharingTheScroll />
</div>;

Trade-offs: features that rely on the table's own scrollport degrade. Pinned columns stick against whatever scroll container the parent provides, which usually works, but the custom pinned-columns scrollbar does not render, and the native one is left visible instead.fixedHeader still creates a vertical scroll container regardless, since a height cap without overflow is meaningless. Leave responsive on (the default) unless one of the cases above applies.

With pagination

Fixed header and pagination work together without any extra configuration. The scroll height only constrains the table body rows. The pagination bar sits below the responsive wrapper and is always fully visible.

<DataTable
  columns={columns}
  data={data}
  fixedHeader
  fixedHeaderScrollHeight="400px"
  pagination
  paginationPerPage={20}
/>;

With selection

The checkbox column header scrolls with all other headers and stays fixed. The select-all checkbox remains accessible at the top of the scrollable area.

<DataTable columns={columns} data={data} fixedHeader fixedHeaderScrollHeight="350px" selectableRows />;

Tracking scroll position with onScroll

The onScroll prop fires on every scroll event inside the table body. It receives a standard React.UIEvent<HTMLDivElement> so you can read scrollTop,scrollLeft, or any other scroll geometry from event.target.

onScroll

Scroll the table body — the current scrollTop value updates in real time.

scrollTop: 0px
#
Name
Department
Salary
Status
1
Aria Chen
Engineering
$80,000
Active
2
Marcus Webb
Product
$81,237
Remote
3
Priya Kapoor
Design
$82,474
On Leave
4
Jordan Ellis
Analytics
$83,711
Contractor
5
Sam Rivera
Sales
$84,948
Active
6
Taylor Brooks
HR
$86,185
Remote
7
Casey Morgan
Engineering
$87,422
On Leave
8
Alex Kim
Product
$88,659
Contractor
9
Morgan Lee
Design
$89,896
Active
10
Drew Park
Analytics
$91,133
Remote
11
Aria Chen 2
Sales
$92,370
On Leave
12
Marcus Webb 2
HR
$93,607
Contractor
13
Priya Kapoor 2
Engineering
$94,844
Active
14
Jordan Ellis 2
Product
$96,081
Remote
15
Sam Rivera 2
Design
$97,318
On Leave
16
Taylor Brooks 2
Analytics
$98,555
Contractor
17
Casey Morgan 2
Sales
$99,792
Active
18
Alex Kim 2
HR
$101,029
Remote
19
Morgan Lee 2
Engineering
$102,266
On Leave
20
Drew Park 2
Product
$103,503
Contractor
21
Aria Chen 3
Design
$104,740
Active
22
Marcus Webb 3
Analytics
$105,977
Remote
23
Priya Kapoor 3
Sales
$107,214
On Leave
24
Jordan Ellis 3
HR
$108,451
Contractor
25
Sam Rivera 3
Engineering
$109,688
Active
26
Taylor Brooks 3
Product
$110,925
Remote
27
Casey Morgan 3
Design
$112,162
On Leave
28
Alex Kim 3
Analytics
$113,399
Contractor
29
Morgan Lee 3
Sales
$114,636
Active
30
Drew Park 3
HR
$115,873
Remote
31
Aria Chen 4
Engineering
$117,110
On Leave
32
Marcus Webb 4
Product
$118,347
Contractor
33
Priya Kapoor 4
Design
$119,584
Active
34
Jordan Ellis 4
Analytics
$120,821
Remote
35
Sam Rivera 4
Sales
$122,058
On Leave
36
Taylor Brooks 4
HR
$123,295
Contractor
37
Casey Morgan 4
Engineering
$124,532
Active
38
Alex Kim 4
Product
$125,769
Remote
39
Morgan Lee 4
Design
$127,006
On Leave
40
Drew Park 4
Analytics
$128,243
Contractor

Prop reference

PropTypeDefaultDescription
responsivebooleantrueWrap the table in a horizontally scrollable container. Disable only when a parent element owns scrolling, see Turning the scroll container off.
fixedHeaderbooleanfalseStick the column header at the top when scrolling.
fixedHeaderScrollHeightstring"100vh"Max height of the scrollable body when fixedHeader is on.
onScroll(event) => void-Called when the user scrolls the table body. Works with fixedHeader on or off.

See it combined with other features in the Audit log viewer recipe.