Skip to content

Tabs indicator custom width and position #10465

@jody-zeitler

Description

@jody-zeitler
  • 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.

segmented_tabs

Your Environment

Tech Version
Material-UI 1.0.0-beta.34
React 16.2.0
browser Chrome 64

Metadata

Metadata

Labels

scope: tabsChanges related to the tabs.type: new featureExpand the scope of the product to solve a new problem.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions