简体   繁体   English

如何在 react-admin 中更改侧边栏字体颜色?

[英]How to change side-bar font color in react-admin?

I'be been using react-admin and following the guides.我一直在使用 react-admin 并遵循指南。 I am able to change the background color, the top-bar-menu color and the top-bar-menu font color.我可以更改背景颜色、顶部栏菜单颜色和顶部栏菜单字体颜色。 I can also change all font sizes.我还可以更改所有字体大小。

However, I am unable to change the side-bar-menu font color .但是,我无法更改侧栏菜单字体颜色 I read a million guides and tried a million methods but absolutely nothing seems to change the side-bar-menu font color.我阅读了一百万份指南并尝试了一百万种方法,但似乎绝对没有任何改变侧边栏菜单字体颜色的方法。 I tried sx , styles , theme , <Menu /> & <Layout/> , and more.我尝试了sxstylestheme<Menu /> & <Layout/>等等。 Also the guides in react-admin's page seem to based on very outdated @mui libraries.此外,react-admin 页面中的指南似乎基于非常过时的@mui 库。

I tried implementing my own <Menu /> & <Layout/> , but nothing I did in sx or styles had any effect on font color.我尝试实现自己的<Menu /> & <Layout/> ,但我在sxstyles中所做的任何事情都没有对字体颜色产生任何影响。

Can anyone tell me specifically and clearly how to change the font color of the side-bar-menu in react-admin?谁能具体清楚地告诉我如何在 react-admin 中更改侧边栏菜单的字体颜色?

This is the code that I use to change other fonts & colors.这是我用来更改其他fonts 和 colors 的代码。

export const myTheme = {
  palette: {
    background: {
      default: `#263238` // background color
    },
    primary: {
      main: `#263238`, // has no effect on anything
      contrastText: `#81C784`, // has no effect on anything
    },
    secondary: {
      main: `#263238`, // top-bar color
      contrastText: `#81C784`, // top-bar font color
    }
  },
  typography: {
    fontSize: 25, // affects all text
  }
}

In app.tsx;在 app.tsx 中; I use <Admin theme={myTheme}... ></Admin>我使用<Admin theme={myTheme}... ></Admin>

Other properties of theme seem to have to effect either.主题的其他属性似乎也有影响。

I believe you have to use palette.text.primary for that:我相信你必须为此使用palette.text.primary

export const myTheme = {
  palette: {
    background: {
      default: `#263238` // background color
    },
    primary: {
      main: `#263238`, // has no effect on anything
      contrastText: `#81C784`, // has no effect on anything
    },
    secondary: {
      main: `#263238`, // top-bar color
      contrastText: `#81C784`, // top-bar font color
    },
    text: {
        primary: '#263238',
    },
  },
  typography: {
    fontSize: 25, // affects all text
  }
}

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

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