search

Home  >  Q&A  >  body text

How to avoid vertical gaps between table header cells in Material UI?

<p>Vertical gaps exist between header cells in MUI tables. How to get rid of them? </p> <p>The following is a reproduction of the error in codesandbox: https://codesandbox.io/s/mui-material-table-sticky-header-forked-euilo3?file=/tsconfig.json</p> <p>I tried applying a style: </p> <pre class="brush:php;toolbar:false;">border: "none", borderCollapse: "collapse", margin: 0,</pre> <p>This error only occurs at certain resolutions and when scrolling the table. </p>
P粉262113569P粉262113569435 days ago489

reply all(1)I'll reply

  • P粉529245050

    P粉5292450502023-09-06 12:54:19

    When inspecting the elements, I can see padding: 6px 16px; on the th and td elements. So the extra gap is actually correct as it is applied to both header cells and row cells

    You can change the header cell gap by just setting padding:0 or any value:

     border: "none",
     borderCollapse: "collapse",
     margin: 0,
     padding: 0,
    

    But you must also do the same with the row cells to keep them aligned.

    reply
    0
  • Cancelreply