Disable Material UI Tabs indicator animation with a prop
Asked Answered
M

4

6

I am using Material UI tabs for my navigation menu.

I want to disable the animation from the indicator when navigating to another route.

I know there is a object prop TabIndicatorProps. But what is the key inside it to disable the animation? Or is it not there and do I have to do it with CSS?

<Tabs
 value={value}
 TabIndicatorProps={{ ?? }}
>
Manualmanubrium answered 17/8, 2021 at 9:44 Comment(0)
E
7

Looks like the easiest way to do this is with CSS, like this:

<Tabs
  value={value}
  TabIndicatorProps={{
    style: {transition: 'none'}
  }}
>

Tested on Material UI version 4.11. I found this by looking at source code (version 4.x) for the TabIndicator component.

This should work in Material 5.x, because it also uses transition CSS property, see source code for latest version.

Emrick answered 17/9, 2021 at 11:22 Comment(0)
S
7
<Tabs
  value={value}
  TabIndicatorProps={{
    style: { display: 'none' }
  }}
>

If you want to remove the indicator of MUI Tab, you need to give {display: "none"} prop inside of Tabs' TabIndicatorProps prop.

It will work correctly at any time to remove indicator of MUI Tabs. Good luck.

Solidify answered 20/12, 2022 at 9:21 Comment(1)
That would remove it instead of disabling the animationTeraterai
E
2

in mui 5, you can do it like this

<Tabs
  sx={{ '& .MuiTabs-indicator': { display: 'none' } }}
>
</Tabs>
Eglanteen answered 6/3, 2023 at 3:26 Comment(0)
T
2

Hiden: true worked for me (:

(Mui v5)

<Tabs
 value={value}
 TabIndicatorProps={{ hidden: true }}
>

P.S: I then noticed that I don't need a Tabs&Tabs components, but rather a simple Box with Buttons. AND THEN I came upon the AppBar&ToolBar which are exactly what I need (: (link: https://mui.com/material-ui/react-app-bar/#app-bar-with-responsive-menu)

Tarmac answered 16/12, 2023 at 22:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.