React-table: Hide <th> headers

Created on 25 Sep 2017  路  4Comments  路  Source: tannerlinsley/react-table

I can't find an option to hide <th>
And if I do Header: null I still can see the empty <th>
I'm pretty sure I'm missing something.

Thanks for helping!

Most helpful comment

We can hide (or customise) the table header using TheadComponent props as suggested by tannerlinsley as shown in below example:

const TheadComponent = props => null; // a component returning null (to hide) or you could write as per your requirement
<ReactTable 
    data={this.state.data}
    TheadComponent={TheadComponent}
    columns={columns}
/>

All 4 comments

There is no option to hide the header. You could pass a custom header component that renders nothing using the TheadComponent prop and a noop component.

This is a question of implementation. We invite you to join the slack channel and ask for help there or on stack overflow. Thanks!

Hi manelgarcia,
You can use

getTheadThProps={function}

As a property for your reactTable to control each header style.
if you want to hide a specific header giving it's title you can do:

getTheadThProps={this.injectThProps}

with

 injectThProps = (state, rowInfo, column) => {
    if (column.Header === 'myHeaderTitle') {
      return {
        style: { display: 'none' }; // override style for 'myHeaderTitle'.
      }
    }
    // However you should return an object, if there is no styles you want to override do
  return {}; // no styles.
  }

Thanks! 馃憤

We can hide (or customise) the table header using TheadComponent props as suggested by tannerlinsley as shown in below example:

const TheadComponent = props => null; // a component returning null (to hide) or you could write as per your requirement
<ReactTable 
    data={this.state.data}
    TheadComponent={TheadComponent}
    columns={columns}
/>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexanderwhatley picture alexanderwhatley  路  3Comments

LeonHex picture LeonHex  路  3Comments

Abdul-Hameed001 picture Abdul-Hameed001  路  3Comments

mlajszczak picture mlajszczak  路  3Comments

mellis481 picture mellis481  路  3Comments