MRT logoMaterial React Table

Sticky Header Example

Material React Table allows you to easily make the header and footer sticky while scrolling. See the Sticky Header Feature Guide for more information.

More Examples

Demo

Open StackblitzOpen Code SandboxOpen on GitHub
DylanMurray[email protected]East Daphne
RaquelKohler[email protected]Columbus
ErvinReinger[email protected]South Linda
BrittanyMcCullough[email protected]Lincoln
BransonFrami[email protected]New York
BenMurray[email protected]Salt Lake City
ElenaSmith[email protected]Los Angeles
MichaelJohnson[email protected]Chicago
SophiaBrown[email protected]Houston
LucasDavis[email protected]Phoenix
OliviaGarcia[email protected]Philadelphia
LiamRodriguez[email protected]San Antonio
EmmaMartinez[email protected]San Diego
NoahHernandez[email protected]Dallas
AvaLopez[email protected]San Jose
WilliamGonzalez[email protected]Austin
IsabellaWilson[email protected]Jacksonville
JamesAnderson[email protected]Fort Worth
MiaThomas[email protected]Columbus
AlexanderTaylor[email protected]Charlotte
GraceMoore[email protected]Indianapolis
EthanWhite[email protected]San Francisco
LilyHarris[email protected]Seattle
DanielMartin[email protected]Denver
ZoeJackson[email protected]Boston
MatthewThompson[email protected]Nashville
EllaGarcia[email protected]Detroit
DavidMartinez[email protected]Portland
AriaRobinson[email protected]Las Vegas
JosephClark[email protected]Baltimore

Source Code

1import { useMemo } from 'react';
2import {
3 MaterialReactTable,
4 useMaterialReactTable,
5 type MRT_ColumnDef,
6} from 'material-react-table';
7import { data, type Person } from './makeData';
8
9const Example = () => {
10 const columns = useMemo<MRT_ColumnDef<Person>[]>(
11 //column definitions...
36 );
37
38 const table = useMaterialReactTable({
39 columns,
40 data,
41 enableBottomToolbar: false,
42 enableStickyHeader: true,
43 enableStickyFooter: true,
44 enablePagination: false,
45 muiTableContainerProps: { sx: { maxHeight: '400px' } },
46 muiTableBodyCellProps: {
47 sx: (theme) => ({
48 backgroundColor:
49 theme.palette.mode === 'dark'
50 ? theme.palette.grey[900]
51 : theme.palette.grey[50],
52 }),
53 },
54 });
55
56 return <MaterialReactTable table={table} />;
57};
58
59export default Example;
60

View Extra Storybook Examples