MRT logoMantine React Table

On This Page

    Column Actions Feature Guide

    By default, Mantine React Table renders a column actions button for each column header. It contains a drop-down menu to help your users use the other features of the table. All of these actions can be triggered in some other way other than from this drop-down menu, so this serves as a UI/UX alternative to make sure your users can find many of the table features easily.

    Relevant Table Options

    #
    Prop Name
    Type
    Default Value
    More Info Links
    1booleantrueMRT Column Actions Docs
    2ActionIconProps | (({table, column }) => ActionIconProps);Mantine ActionIcon Docs
    3({ closeMenu, column, table, internalColumnMenuItems }) => ReactNode

    Relevant Column Options

    #
    Column Option
    Type
    Default Value
    More Info Links
    1booleanMRT Column Actions Docs
    2ActionIconProps | ({ column, table }) => ActionIconPropsMantine ActionIcon API
    3

    Disable or Hide Column Actions Buttons

    You can set the enableColumnActions table option to false to disable this feature and hide the button in each column header completely.

    const table = useMantineReactTable({
      data,
      columns,
      enableColumnActions: false,
    });

    Alternatively, if you only want to hide the column actions button in specific columns, you can set the enableColumnActions column option to false instead.

    In this demo, we disable the column actions button for the 'ID' column.

    ID
    First Name
    Last Name
    1DylanMurray
    2RaquelKohler

    Rows per page

    1-2 of 2

    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';
    
    const Example = () => {
      const columns = useMemo(
        () =>
          [
            {
              accessorKey: 'id',
              enableColumnActions: false,
              header: 'ID',
            },
            {
              accessorKey: 'firstName',
              header: 'First Name',
            },
            {
              accessorKey: 'lastName',
              header: 'Last Name',
            },
          ] as MRT_ColumnDef<(typeof data)[0]>[],
        [],
      );
    
      const data = useMemo(
        () => [
          {
            id: 1,
            firstName: 'Dylan',
            lastName: 'Murray',
          },
          {
            id: 2,
            firstName: 'Raquel',
            lastName: 'Kohler',
          },
        ],
        [],
      );
    
      return <MantineReactTable columns={columns} data={data} />;
    };
    
    export default Example;

    Custom Column Actions Menu

    If you do not like the default column actions menu items that Mantine React Table generates, you can provide your own custom menu items with the renderColumnActionsMenuItems option.

    const table = useMantineReactTable({
      data,
      columns,
      renderColumnActionsMenuItems: ({ internalColumnMenuItems }) => (
        <>
          {internalColumnMenuItems} //optionally include the default menu items
          <Divider />
          <Menu.Item>Item 1</Menu.Item>
          <Menu.Item>Item 2</Menu.Item>
        </>
      ),
    });
    
    return <MantineReactTable table={table} />;
    ID
    First Name
    Last Name
    1DylanMurray
    2RaquelKohler

    Rows per page

    1-2 of 2

    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,
      useMantineReactTable,
      type MRT_ColumnDef,
    } from 'mantine-react-table';
    import { Menu, Divider } from '@mantine/core';
    
    const data = [
      {
        id: 1,
        firstName: 'Dylan',
        lastName: 'Murray',
      },
      {
        id: 2,
        firstName: 'Raquel',
        lastName: 'Kohler',
      },
    ];
    
    const Example = () => {
      const columns = useMemo<MRT_ColumnDef<(typeof data)[0]>[]>(
        () => [
          {
            accessorKey: 'id',
            header: 'ID',
            renderColumnActionsMenuItems: () => (
              <>
                <Menu.Item
                  onClick={() => {
                    console.log('Item 1 clicked');
                  }}
                >
                  Item 1
                </Menu.Item>
                <Menu.Item
                  onClick={() => {
                    console.log('Item 2 clicked');
                  }}
                >
                  Item 2
                </Menu.Item>
              </>
            ),
          },
          {
            accessorKey: 'firstName',
            header: 'First Name',
            renderColumnActionsMenuItems: ({ internalColumnMenuItems }) => (
              <>
                {internalColumnMenuItems}
                <Divider />
                <Menu.Item
                  onClick={() => {
                    console.log('Item 1 clicked');
                  }}
                >
                  Item 1
                </Menu.Item>
                <Menu.Item
                  onClick={() => {
                    console.log('Item 2 clicked');
                  }}
                >
                  Item 2
                </Menu.Item>
              </>
            ),
          },
          {
            accessorKey: 'lastName',
            header: 'Last Name',
            renderColumnActionsMenuItems: ({ internalColumnMenuItems }) => (
              <>
                <Menu.Item>Item 1</Menu.Item>
                <Menu.Item>Item 2</Menu.Item>
                <Divider />
                {internalColumnMenuItems}
              </>
            ),
          },
        ],
        [],
      );
    
      const table = useMantineReactTable({
        columns,
        data,
        //renderColumnActionsMenuItems //or you could define the menu items here for all columns
      });
    
      return <MantineReactTable table={table} />;
    };
    
    export default Example;

    Justify Column Actions Button

    By default, the column actions button is left aligned directly after the column header text and any sort or filter labels that may be present. If you want to change this, you can use a CSS selector in mantineTableHeadCellProps to change the justify-content property of the column header container.

    ID
    First Name
    Last Name
    1DillonHowler
    2RossEverest

    Rows per page

    1-2 of 2

    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 } from './makeData';
    
    const Example = () => {
      const columns = useMemo<MRT_ColumnDef<(typeof data)[0]>[]>(
        () => [
          {
            accessorKey: 'id',
            header: 'ID',
          },
          {
            accessorKey: 'firstName',
            header: 'First Name',
          },
          {
            accessorKey: 'lastName',
            header: 'Last Name',
          },
        ],
        [],
      );
    
      return (
        <MantineReactTable
          columns={columns}
          data={data}
          mantineTableHeadCellProps={{
            style: {
              '& .mantine-TableHeadCell-Content': {
                justifyContent: 'space-between',
              },
            },
          }}
        />
      );
    };
    
    export default Example;

    View Extra Storybook Examples