Skip to content

Can a Datatable be horizontally scrollable? #1512

Answered by theetrain
cgildenia asked this question in Q&A
Discussion options

You must be logged in to vote

@cgildenia I have this CSS set up for my DataTables:

  /*
    Table wrapper used to opt into sticky styles

    Usage:
    <div class="table-wrapper">
      <DataTable />
    </div>
  */
  :global(.table-wrapper) {
    overflow-x: scroll;
  }
  /*
    Keep header and toolbar visible on
    wide tables with sticky content
  */
  :global(.table-wrapper .bx--data-table-container) {
    overflow: auto;
  }
  :global(.table-wrapper .bx--data-table-header, .table-wrapper
      .bx--table-toolbar, .table-wrapper .bx--pagination) {
    position: sticky;
    left: 0;
  }

And then you can wrap your DataTable with the table-wrapper class:

<div class="table-wrapper">
  <DataTable {...tableProps} />
</d…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@dybxin
Comment options

@theetrain
Comment options

Answer selected by metonym
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants