I created a custom <Tab/>
and I want to control its selection color by using the following code:
Sandbox Demo Code
export const Tab = styled(MuiTab)({ "&.Mui-selected": { color: "red" } });
However, I found:
1. Directly apply custom style components => The selected color is red
2.Wrapping custom style componentsin a self-created component => does not work, not even the default selected color
<Tabs value={value} variant="scrollable"> <Tab label="Tab" value={1} /> //选中颜色 = 默认值 <TestTab label="TestTab" value={2} /> //选中颜色 = 默认值(问题在这里) <Styled.Tab label="Styled.Tab" value={3} /> //选中颜色 = 红色(好的,但我想包装在自创建的组件中) </Tabs>
Is this normal behavior that MUI does not recognize self-created Tabs?
How to create a wrapper component that renders your custom Tab component this way
TestTab
instead of usingStyled.Tab