6

I have a problem to get pretty basic functionality, ie. I'd like to set horizontal scroll on React table when the page is less wider then the table size. There is nothing unusual in my code but I'll leave it here anyway:

<ReactTable
  data={bookingPerson}
  columns={columns}
  className="-striped -highlight"
  defaultPageSize={7}
  loading={loading}
/>
5
  • 1
    Have you tried adding style prop having some width like this? codesandbox.io/s/6ll7jk01yk Commented Aug 29, 2018 at 13:02
  • This is really weird but I think I have the same structure with the same values as in the example you showed but still it is not scrolling even though in example it does. Commented Aug 29, 2018 at 16:52
  • Maybe the style is getting overridden somewhere. Can you please inspect the overflow property for the react-table container? It will give you some hint. Commented Aug 29, 2018 at 17:09
  • No, unfortunately it is not so simple ;) I've checked it in Firefox as well and there I can see scrollbar and I can use it grabbing it but the mouse scrolling does not work. In chrome you even cannot see scrollbar. Commented Aug 30, 2018 at 9:28
  • But after all I think it is not a behaviour of react-table because even a div with a fixed height, fixed width and overflow: scroll does not scroll in chrome Commented Aug 30, 2018 at 10:19

1 Answer 1

3

Just simply add style with a height of 400px, that will force it to be scroll able.

<ReactTable
      data={bookingPerson}
      columns={columns}
      className="-striped -highlight"
      defaultPageSize={7}
      loading={loading}
      style={{
        height: "400px"
      }}
 />
Sign up to request clarification or add additional context in comments.

1 Comment

I had a similar issue trying to avoid whole page horizontal scroll when having another inner React Table with many columns inside the "parent" table's expandable area... I solved it with this: style={{ width: "80vw" }} I used the width with viewport unit (vw) because I needed a dynamic width for the parent table. This way the inner table's horizontal scroll is displayed automatically depending on screen width size.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.