How to initially hide the Show/Hide columns button in material react table?

1.3k Views Asked by At

How can I initially hide the "Show/Hide columns" button in material-react-table?

show/hide column button

I searched through the documentation but couldn't find any information on how to hide this button.

Thanks in advance.

2

There are 2 best solutions below

0
On

You can hide all of the default toolbar buttons using these settings.

enableHiding: false,
enableGlobalFilter: false,
enableFullScreenToggle: false,
enableDensityToggle: false,
enableFilters: false

The docs don't cover these settings unfortunately, if you choose to hide the toolbar entirely you will lose access to certain features such as the top of table progress bar.

1
On

You can remove the column hiding button from the top toolbar by setting the enableHiding prop to false in Material React Table.

Example:

<MaterialReactTable
  columns={columns}
  data={data}
  enableHiding={false}
/>

Result:

enter image description here

Working CodeSandbox: https://codesandbox.io/p/sandbox/dreamy-browser-s8893s?file=%2Fsrc%2FTS.tsx%3A106%2C36