-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Tabs] Align left #4420
Comments
<div style={{backgroundColor: 'sameAsTabs'}}>
<Tabs value={window.location.pathname} style={{width: 200, float: 'left'}}>
<Tab
label="Item One"
value="/"
onActive={this.handleActiveTab}
/>
<Tab
label="Item Two"
value="/item2"
onActive={this.handleActiveTab}
/>
</Tabs>
</div> This sets the Tabs container to the desired width. Alternatively you can probably set each tab to a fixed width, but I didn't try. |
Well… that's more a hack than a real solution. I don't want to force a fixed width to the tabs nor the container (and forcing a tab width will break the ink bar). I'd rather want it to naturally fit what's inside the tabs (text or icon) instead of expanding to max width. |
Yes, it's a workaround for sure. |
The fixedTabWidth property sets a fixed width to each tab label and aligns them to the left instead of using full width. If the prop is not set, behavior is back to normal. This solves issue mui#4420. The docs have also been updated with information and an example for this prop.
The fixedTabWidth property sets a fixed width to each tab label and aligns them to the left instead of using full width. If the prop is not set, behavior is back to normal. This solves issue mui#4420. The docs have also been updated with information and an example for this prop.
The Tab component has a new prop of type number: labelWidth. This number is the width of the label in pixels. The user must either set this prop to every tab or none. If this condition is not met, the ink bar is not drawn, and a warning is displayed in the console. The docs have also been updated with information and an example for this prop. This solves issue mui#4420. This approach was suggested in mui#5301.
The Tab component has a new prop of type number: labelWidth. This number is the width of the label in pixels. The user must either set this prop to every tab or none. If this condition is not met, the ink bar is not drawn, and a warning is displayed in the console. The Tabs directory has a new file: TabUtils.js. For now this file has a single function: calculateTabWidthAndInkbarPosition which is necessary now that widths are variable. A test for this function has been written in the TabUtils.spec.js file. The docs have also been updated with information and an example for this prop. This solves issue mui#4420. This approach was suggested in mui#5301.
An initial migration of the |
@mbrookes I can't get the desired results using the technique. Can you help. ` <div style={{backgroundColor:'#4AA4B8'}}> Initially it does not work i.e Tab A does not work but Tab B and Tab C works fine. |
Here's the webpackbin link to it |
@pavanmehta91 The issue was closed. Move to the v1-beta release if you need the feature. |
Use this on Tab element |
Description
Using full width to display tabs is not always the best experience especially when width is large (like on desktop or tablet) and there is few tabs.
It would be nice to have an option to have tabs aligned on the left instead of centered.
Even better tabs could be auto aligned on left or center according to the current container width and scroll would auto activate when this width is too small.
Images & references
This is the how tabs are currently displayed on "large" screen:
This is what I'd like to have:
An other example using Polymer paper tabs (in a toolbar):
And with Angular material:
The text was updated successfully, but these errors were encountered: