Tabs indicator custom width and position
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
I’d like the ability to transform the indicator style (namely width and left) within the Tabs component based on the default value. This would be in the form of an optional function prop that looks like this:
function transformIndicatorStyle({left, width}) {
return {
left: left + 6,
width: width - 12,
};
}
This function would be invoked either before setting the indicatorStyle state value, or before the style is passed to the TabIndicator child during render.
Current Behavior
The Tabs indicator is locked to the left and width of the currently selected tab’s getBoundingClientRect.
Steps to Reproduce (for bugs)
This sandbox demonstrates how far I’m able to go for indicator customization. I’ve modified the height and margins of the indicator using class overrides, but I’m not able to access or modify the width because it’s a function of the selected tab size. Notice the overhang on the right side of the selection.
https://codesandbox.io/s/6j663n24zw
Context
We are creating a component that wraps AppBar and Tabs. It has a segmented option which places the indicator underneath the tab (z-axis) at full height, similar to what was done for #10123, with some margin around the sides. Style overrides allow us to mostly accomplish what we want, but we’re unable to find a way to modify the indicator width so that it plays nicely with the margin.

Your Environment
| Tech | Version |
|---|---|
| Material-UI | 1.0.0-beta.34 |
| React | 16.2.0 |
| browser | Chrome 64 |
Issue Analytics
- State:
- Created 6 years ago
- Comments:18 (7 by maintainers)
Top Related StackOverflow Question
@HiranmayaGundu Ok, can you add this example in the documentation? 😄 https://codesandbox.io/s/xl526z333q alongside this demo? https://material-ui.com/demos/tabs/#customized-tabs
Thanks!
I’ve realized I can accomplish what I want by adding left/right margin to the tab itself, so the bounding box is calculated appropriately. Updated sandbox:
https://codesandbox.io/s/9z9z4rkjny