Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the height of the tab indicator in material ui

I would like to change the height/thickness of the tab indicator in material ui

From this

enter image description here

To this

enter image description here

like image 891
Nick Hufler Avatar asked Dec 21 '17 14:12

Nick Hufler


People also ask

How do I change the tab color in MUI?

1, you can do this: import Tabs from '@material-ui/core/Tabs'; import { withStyles } from '@material-ui/core/styles'; const StyledTabs = withStyles({ indicator: { backgroundColor: 'orange' } })(Tabs);

How do you show active tabs in Materialui?

You can use the state to set the initial tab select. Show activity on this post. The value of the currently selected Tab . If you don't want any selected Tab , you can set this property to false .


3 Answers

If you want to use sx in MUI v5, then:

<Tabs
  TabIndicatorProps={{
    sx: {
      bgcolor: "orange"
      height: "10px"
    }
  }}
  onChange={handleChange}
  value={value}
>
  <Tab label="Item One" />
  <Tab label="Item Two" />
  <Tab label="Item Three" />
</Tabs>

You can change it with TabIndicatorProps.

<Tabs
  TabIndicatorProps={{
    style: {
      height:"10px",
    }
  }}
  onChange={handleChange}
  value={value}
>
  <Tab label="Item One" />
  <Tab label="Item Two" />
  <Tab label="Item Three" />
</Tabs>
like image 124
karan khanna Avatar answered Oct 05 '22 09:10

karan khanna


The indicatorClassName property was removed in the v1.0.0-beta.37 release. The classes property is now the standard way to customize the internal styles of components in v1.

For details about this change, see the release notes

// Define custom styles
const styles = theme => ({
  bigIndicator: {
    height: 5
  }
})


<Tabs
  /* use the `classes` property to inject styles for the indicator class */
  classes={{ indicator: classes.bigIndicator }}
  onChange={handleChange}
  value={value}
>
  <Tab label="Item One" />
  <Tab label="Item Two" />
  <Tab label="Item Three" />
</Tabs>

Here is a complete working example on code sandbox

like image 44
Luke Peavey Avatar answered Oct 05 '22 07:10

Luke Peavey


You can pass a class name to the TabIndicator via the Tabs component by using its indicatorClassName prop:

  const styles = theme => ({
    bigIndicator: {
      height: 5,
    },
  });
    <Tabs indicatorClassName={classes.bigIndicator} value={value} onChange={this.handleChange}>
      <Tab label="Item One" />
      <Tab label="Item Two" />
      <Tab label="Item Three" href="#basic-tabs" />
    </Tabs>

Here is a working example on codesandbox

like image 44
Ken Gregory Avatar answered Oct 05 '22 08:10

Ken Gregory