Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force tab to fit to small space in Material UI?

As per doc, I tried fullWidth, centered for tabs, Does not seem to work. How do force tabs to re-adjust to given screen size ?

I am using latest beta v23enter image description here

like image 597
user2616355 Avatar asked Jan 04 '23 01:01

user2616355


1 Answers

I think the easiest way to force the tabs to fit a smaller container width, would be:

<Tab style={{ minWidth: 50 }} label="item" />

The default minimums are 160px for medium-and-up, 72px for small-and-down screen sizes.

Depending on how small the fit should be, you can also do other kinds of overrides on padding and font. I tried out a few techniques on CodeSandbox.

Remember, the more we compact the tabs, the worse usability. There should be other workarounds too! For instance, shortening the label texts, using icons, or restructuring.

like image 91
Rikku Avatar answered Jan 13 '23 14:01

Rikku