【问题标题】:Material UI 1.0 beta, accent color raised button with white textMaterial UI 1.0 beta,带有白色文本的强调色凸起按钮
【发布时间】:2018-01-23 04:48:48
【问题描述】:

我正在使用新的 Material-ui 1.0,我希望所有凸起的按钮都是我的应用程序的强调色 (#00c853),并且按钮上的文本应该是白色的。

<Button raised color="accent">Button</Button>

按钮现在是绿色的,但文本是黑色的,我无法将文本颜色设置为白色。

我该怎么做?

【问题讨论】:

    标签: reactjs material-ui


    【解决方案1】:

    按钮的文本颜色由 Material UI 根据定义的调色板自动确定。但是,您可以使用 global style override 为按钮设置新的文本颜色:

    import { MuiThemeProvider, createMuiTheme } from 'material-ui/styles';
    
    const theme = createMuiTheme({
      overrides: {
        MuiButton: {
          raisedAccent: {
            color: 'white !important'
          }
        }
      }
    });
    
    ReactDOM.render(
      <MuiThemeProvider theme={theme}>
        <YourApp/>
      </MuiThemeProvider>,
      document.querySelector('#app')
    );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-15
      • 1970-01-01
      • 2019-02-08
      • 2011-01-31
      • 2016-09-04
      • 1970-01-01
      • 1970-01-01
      • 2023-03-08
      相关资源
      最近更新 更多