React-table: Word Wrap in Table Header

Created on 8 Jan 2018  路  4Comments  路  Source: tannerlinsley/react-table

Is there a way to automatically wrap the text in the table header? I have several columns and the text in the headers is being truncated.

headertruncated

Most helpful comment

A more general solution is to add a custom class:

.wordwrap {
  white-space: pre-line !important;
  word-wrap: break-word;
}

Then add the following prop your column definition: headerClassName: "wordwrap"

All 4 comments

Change the overflow to unset - by default, overflow is hidden on every cell.

You can do that either by setting the headerStyle on each column definition or using one of the appropriate get*Props overrides to return the style you want.

Thanks for your help Gary. That removed the ellipsis for me, but wasn't what I was after. I was trying to get the text to wrap to the next line. I was able to force line breaks with this:

Header:() => <div>This is my<br/>long header</div>

A more general solution is to add a custom class:

.wordwrap {
  white-space: pre-line !important;
  word-wrap: break-word;
}

Then add the following prop your column definition: headerClassName: "wordwrap"

Or if you want to apply your wordwarp class to all headers:

import ReactTable, { ReactTableDefaults } from 'react-table'

const columnDefaults = { ...ReactTableDefaults.column, headerClassName: 'wordwrap' }
...
return (
  <ReactTable
    ...Other props go here
    column={columnDefaults}
  />
)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

bdkersey picture bdkersey  路  3Comments

kieronsutton00 picture kieronsutton00  路  3Comments

panfiva picture panfiva  路  3Comments

tremby picture tremby  路  3Comments

dwjft picture dwjft  路  3Comments