MRT logoMantine React Table

On This Page

The sticky header and footer feature allows you to keep the header and footer of the table visible while scrolling through the table. This is useful when you have a large table and want to keep the header and footer visible at all times.

Relevant Table Options

#
Prop Name
Type
Default Value
More Info Links
1boolean
2boolean
3BoxProps | ({ table }) => BoxPropsMantine Box Docs

Enable Sticky Header

Enabling the sticky header is as simple as setting the enableStickyHeader table option to true. This will make the header of the table stick to the top and remain visible while scrolling through the table.

When the sticky header is enabled, you will probably also want to give the table a maxHeight so that the table can scroll vertically, and keep the header visible. You can do this by styling the table container with the mantineTableContainerProps table option.

If no maxHeight is specified, the table container will default to a 100vh maxHeight when enableStickyHeader is enabled.

const table = useMantineReactTable({
  columns,
  data,
  enableStickyHeader: true,
  mantineTableContainerProps: { style: { maxHeight: '500px' } },
});

Similarly, enabling the sticky footer is as simple as setting the enableStickyFooter table option to true. This will make the footer of the table stick to the bottom of the table and always be visible, even before the table is scrolled to the bottom.

const table = useMantineReactTable({
  columns,
  data,
  enableStickyFooter: true,
});
First Name
Last Name
Email
City
DylanMurraydmurray@yopmail.comEast Daphne
RaquelKohlerrkholer33@yopmail.comColumbus
ErvinReingerereinger@mailinator.comSouth Linda
BrittanyMcCulloughbmccullough44@mailinator.comLincoln
BransonFramibframi@yopmain.comNew York
KevinKleinkklien@mailinator.comNebraska
First NameLast NameEmailCity

Rows per page

1-6 of 6

import '@mantine/core/styles.css';
import '@mantine/dates/styles.css'; //if using mantine date picker features
import 'mantine-react-table/styles.css'; //make sure MRT styles were imported in your app root (once)
import { useMemo } from 'react';
import { MantineReactTable, type MRT_ColumnDef } from 'mantine-react-table';
import { data, type Person } from './makeData';

const Example = () => {
  const columns = useMemo<MRT_ColumnDef<Person>[]>(
    () => [
      {
        accessorKey: 'firstName',
        header: 'First Name',
        footer: 'First Name',
      },
      {
        accessorKey: 'lastName',
        header: 'Last Name',
        footer: 'Last Name',
      },
      {
        accessorKey: 'email',
        header: 'Email',
        footer: 'Email',
      },
      {
        accessorKey: 'city',
        header: 'City',
        footer: 'City',
      },
    ],
    [],
  );

  return (
    <MantineReactTable
      columns={columns}
      data={data}
      enableStickyHeader
      enableStickyFooter
      mantineTableContainerProps={{ style: { maxHeight: '300px' } }}
    />
  );
};

export default Example;

View Extra Storybook Examples