如何应用所选主题的颜色

时间:2018-04-10 14:04:21

标签: javascript reactjs material-ui

我正在使用https://material-ui-next.com/,如下所示:

import React, { Component } from 'react';
import { AppBar, Toolbar } from 'material-ui';
import { Typography } from 'material-ui';
import { MuiThemeProvider, createMuiTheme } from 'material-ui/styles';
import {cyan, blue} from 'material-ui/colors';

const theme = createMuiTheme({
  palette: {
    primary:{
      main:blue[900]
    },
    secondary: cyan, 
  },
});

class App extends Component {
  render() {
    return (
      <MuiThemeProvider theme={theme}>
        <AppBar position="static">
          <Toolbar>
          <Typography variant="title">
            Hello
          </Typography>          
          </Toolbar>
        </AppBar>
      </MuiThemeProvider>
    );
  }
}

export default App;  

如您所见,我将主要主题更改为

main:blue[900]

但字体颜色是黑色。如何将字体颜色更改为白色?
查看https://material-ui-next.com/style/color/,字体颜色为白色。

输出是: enter image description here

字体颜色为黑色,但我想更改为白色。

1 个答案:

答案 0 :(得分:1)

尝试将theme对象更改为:

const theme = createMuiTheme({
  palette: {
    primary: {
      main: blue[900]
    },
    text: {
      primary: '#fff',
    }
  }
});

参考:https://material-ui-next.com/customization/themes/