Search code examples
vmware-clarity

How to make the left-most column fit to content in vertical table?


Is there a way to make the left most column fit to it's content in a vertical table? See this screenshot Expectation: enter image description here Actual: enter image description here


Solution

  • Here is one way to auto-fit a columns width to its content using css. On the th element you want to fit to content, add this class:

    .auto-fit {
      width: 1px;
      white-space: nowrap;
    }
    

    StackBlitz with running code is here: https://stackblitz.com/edit/so-52815432-auto-fit-width-to-content