In Material-UI, the TabIndicator
component is a span
rather than simply being a border-bottom of certain elements. This means that in order to customize it with your own border color, you will need to completely remove the default indicator and add your own style, which may require some extra effort.
const useStyles = makeStyles({
indicator: {
background: "none" // Removing MUI indicator
},
tabs: {
"& button": {
padding: 5 // Border size
},
"& button[aria-selected='true']": {
position: "relative",
"&:before": {
content: '""',
position: "absolute",
left: 0,
top: 0,
right: 0,
bottom: 0,
background: "linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)", // Gradient border color
zIndex: 0
},
"& > *": { zIndex: 0 },
"& > .MuiTab-wrapper": {
background: "#fff",
height: "100%"
}
}
}
});
However, if you only need a solid color for your border, the implementation becomes simpler:
const useStyles = makeStyles({
indicator: {
background: "none"
},
tabs: {
"& button[aria-selected='true']": {
border: "3px solid red"
}
}
});
Usage
const classes = useStyles();
return (
<Tabs
className={classes.tabs}
classes={{ indicator: classes.indicator }}
{...props}
>
<Tab label="Item One" />
<Tab label="Item Two" />
<Tab label="Item Three" />
</Tabs>
);
Live Demo
https://codesandbox.io/s/66769333set-border-for-tab-indicator-in-material-ui-909s6?file=/index.tsx