Skip to content

[tabs] Wrong position of indicator & width when using transform:scale. #35631

Closed

Description

@madmonliadd

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example (Updated):
https://codesandbox.io/p/devbox/usage-forked-49jljl

Steps:

  1. Wrap the tabs component with a transform:scaled wrapper / use the link above.

Current behavior 😯

The tabs' indicator's position & width isn't correctly set.

Expected behavior 🤔

The tabs' indicator's position should be exactly below the selected tab, and its width should match exactly the selected tab's width.

Context 🔦

No response

Your environment 🌎

Using the codesandbox above.

Activity

  1. ZeeshanTamboli commented on Dec 27, 2022

    @ZeeshanTamboli
    Member

    You need to target the indicator class on Tabs to style the tabs indicator. See the updated CodeSandbox: https://codesandbox.io/s/usage-forked-l1m7fu?file=/index.js

  2. added
    scope: tabsChanges related to the tabs.
    and removed on Dec 27, 2022
  3. github-actions commented on Dec 27, 2022

    @github-actions
    Contributor

    👋 Thanks for using MUI Core!

    We use GitHub issues exclusively as a bug and feature requests tracker, however,
    this issue appears to be a support request.

    For support, please check out https://mui.com/getting-started/support/. Thanks!

    If you have a question on Stack Overflow, you are welcome to link to it here, it might help others.
    If your issue is subsequently confirmed as a bug, and the report follows the issue template, it can be reopened.

  4. madmonliadd commented on Dec 27, 2022

    @madmonliadd
    Author

    @ZeeshanTamboli You removed the scaled div, of course it'll work when you remove the parent scale.

  5. ZeeshanTamboli commented on Dec 27, 2022

    @ZeeshanTamboli
    Member

    @ZeeshanTamboli You removed the scaled div, of course it'll work when you remove the parent scale.

    @madmonliadd Sorry for that, I didn't read carefully about you saying Wrap the tabs component with a transform:scaled wrapper.

    I don't know why you want to achieve scaling for your use case, but you can increase the scaling by directly applying the styles to the AppBar. Having a unnecessary div in between for scaling is causing the issue of moving the position of the tab indicator. As for the width, it is calculated dynamically under the hood according to the size of the tab and considers various other factors, but you can override it with the .MuiTabs-indicator class if you want to or instead calculate it as per the scaling and apply it.

    See the updated CodeSandbox: https://codesandbox.io/s/usage-forked-1y7g9f?file=/index.js

    I would suggest to use StackOverflow for these type of questions.

    I hope it helps.

  6. madmonliadd commented on Dec 27, 2022

    @madmonliadd
    Author

    @ZeeshanTamboli Hey, thanks for your help, I tried stack overflow without success, it's a bug, not a help request.
    Your codesandbox didn't solve the issue, click other tabs and see how the position of the indicator is incorrect, it's not directly under the selected tab.

  7. ZeeshanTamboli commented on Dec 27, 2022

    @ZeeshanTamboli
    Member

    it's a bug, not a help request.

    It's not a bug. It's just about overriding with the correct styles.

    You have to simply find a way to style the tab indicator properly. Maybe you want to check if you are correctly using transform: scale property. You may not want to scale the indicator or maybe you shouldn't use the scale on tabs in the first place and use sizing. Take a look at the customization of Tabs docs: https://mui.com/material-ui/react-tabs/#customization

  8. carmenchapa commented on Feb 7, 2025

    @carmenchapa

    In case someone else lands here.
    I faced this problem in an app where scaling a parent container was not up to me.
    I could fix it by overriding left style of indicator like below. In my case the fixed values worked.

    const indicatorLefts = {
      first: '0px',
      second: '50px',
      third: '100px',
    }
    ....
    
    <Tabs
      ...
        sx={{
          '& .MuiTabs-indicator': {
           left: `${indicatorLefts[activeTab]} !important`,
         }
       }}
    >
    ...
    </Tabs>
    
  9. AndreFavotto commented on Sep 3, 2026

    @AndreFavotto

    @ZeeshanTamboli
    I see the exact same issue, and it seems like a bug, as opposed to what was said.

    The indicator does not follow the button size if scaling is applied to a parent div.
    In the video below no special handling is applied to the buttons, and they keep their size just fine with parent scaling. The selector should just do the same.

    In my case, the parent container is scaled due to the canvas zoom. I would expect the indicators to follow the size of the button without me needing to "override with the correct styles."

    Screencast.From.2026-09-03.20-38-46.webm

    PS: I am able to reproduce this even on MUI docs by setting transform: "scale(1.2)", transformOrigin: "top left" in any of the parent Boxes of the tab examples in here.

  10. ZeeshanTamboli commented on Sep 30, 2026

    @ZeeshanTamboli
    Member

    I will re-open this and mark it as a bug. The Tabs indicator should follow the Button size as mentioned above.

  11. changed the title [-]Tabs indicator wrong position & width when using transform:scale.[/-] [+][tabs] Wrong position of indicator & width when using transform:scale.[/+] on Sep 30, 2026
  12. maricastroc commented on Sep 30, 2026

    @maricastroc
    Contributor

    I investigated this on the current master and was able to reproduce it.

    The indicator calculation currently mixes transformed viewport measurements from getBoundingClientRect() with local scroller coordinates. With a scaled ancestor, the resulting left/width values already include the scale and are then scaled again when the indicator is rendered.

    I have a small fix that normalizes those measurements back to the scroller's local coordinate space before calculating the indicator position/size, while preserving the existing sub-pixel behavior when no transform is present.

    I'd be happy to open a PR with regression coverage for this.

  13. github-actions commented on Oct 14, 2026

    @github-actions
    Contributor

    This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
    Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.


    @madmonliadd Thanks again for creating this issue! If you have a moment, we would love to hear your thoughts on how we handled it with this short feedback form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: tabsChanges related to the tabs.type: bugIt doesn't behave as expected.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions