Carbon: proposal(tabs): automatic tab width

Created on 24 Sep 2020  ·  5Comments  ·  Source: carbon-design-system/carbon

Summary

Permit me to propose an "auto tab width" property (false by default) that sets the width property of tab items to be "auto," instead of having a maximum width of 10rem.

Justification

The main use case is for using the Tabs component in a narrow column (i.e. 4 columns or fewer). In the screenshot below, the tabs are contained in "4 columns".

compare

Auto tab width with Carbon grid overlaid using the Carbon devtools Chrome extension:

compare-grid

Desired UX and success metrics

This feature would work best with 3 or fewer tabs, or with tabs with short labels.

Desired UX would be to have an autoWidth prop in the React library:

<Tabs>
  <Tab autoWidth label="Tab item 1" />
  ...
</Tabs>
open needs triage 🕵️‍♀️ waiting for author's response 💬 enhancement 💡

Most helpful comment

Weighing in; IIRC the design decision was that "every tab should have the same width", instead of "every tab's width should be _n_ em". Given "every tab should have the same width" cannot be implemented for the width of arbitrary content, we set a specific width by default and let application override our style to set the width that accommodates their contents.

All 5 comments

@emyarod Interesting. So the aesthetic reason for fixed widths is horizontal alignment.

But for auto widths, the tabs can still be aligned on its left side.

I like the suggestion by @aagonzales of having the minimum tab width be determined by the longest tab name – and perhaps rounding up to the nearest mini unit/spacer.

I suppose that if fixed tab widths is a purposeful design decision, then Tabs should not be used in narrow columns?

I think that conclusion is logical but cc @aagonzales for some additional insight into Tabs usage guidelines!

Weighing in; IIRC the design decision was that "every tab should have the same width", instead of "every tab's width should be _n_ em". Given "every tab should have the same width" cannot be implemented for the width of arbitrary content, we set a specific width by default and let application override our style to set the width that accommodates their contents.

Was this page helpful?
0 / 5 - 0 ratings