繁体   English   中英

如何自定义材质 ui 选项卡、选项卡滚动条

[英]how to customize material ui tabs, tabs scroller

在这里,我正在尝试自定义此 mui 选项卡、选项卡颜色和选项卡底部边框颜色。 我试图通过使用 makestyles 等来做到这一点,但没有任何效果。 在此处输入图像描述

我的代码是,

import { makeStyles } from '@mui/styles';
const useStyles = makeStyles({
    tab:{
     "& .MuiButtonBase-root":{
          marginLeft:"25px"

     }
    },
    tabs:{
         "& .MuiTabs-indicator":{
              ml:"30px"
         }
    }
})

此外,我还面临自定义 mui 类的问题。 虽然我使用的是 sx props 的解决方案,但我知道这不是最佳实践。

在此处输入图像描述

const theme = createTheme({
  components: {  
  MuiTabs: {
  styleOverrides: {
    indicator: {
      backgroundColor: 'orange',
      height: 10,
    },
  },
},
}
})

您可以使用属性'&.MuiTab-root.Mui-selected'设置所选标签样式的样式,就像当前标签的边框颜色一样,您可以使用属性TabIndicatorProps并添加 styles 属性,即

export const StyledTab = styled((Tab))({
    '&.MuiTab-root.Mui-selected': {
        color: 'gold',
    },

TabIndicatorProps={{                   
style: {
         backgroundColor: '#f1db29'
       }
}}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM