I have created a custom <Tab/>
and I would like to control its selected-color by using
export const Tab = styled(MuiTab)({
"&.Mui-selected": {
color: "red"
}
});
However, I found that:
1.apply the self-styled component directly => selected-color = red
2.wrap the self-styled component by a self-created component => not working, even no default selected-color
<Tabs value={value} variant="scrollable">
<Tab label="Tab" value={1} /> //selected color = default
<TestTab label="TestTab" value={2} /> //selected color = default (Problem here)
<Styled.Tab label="Styled.Tab" value={3} /> //selected color = red (Good one but I want to wrap in self-created component)
</Tabs>
Is that a normal behavior which MUI does not recognize a self-created Tab?
2
Answers
how about creating a wrapper component that renders your self-styled Tab component
TestTab
like this instead of using theStyled.Tab
The solution of @raman is right.
I’ve edit on your codesandbox: