Can't style datepiker popup dialog

前端 未结 2 1029
一整个雨季
一整个雨季 2021-01-03 03:25

I have a problem with customizing the datepicker popup dialog(For example change color of header). I can\'t style it by attribute style like textField by textFieldStyle. It

相关标签:
2条回答
  • 2021-01-03 03:36

    The only place you can currently override this is the theme:

    import React from 'react';
    import {cyan500} from 'material-ui/styles/colors';
    import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
    import getMuiTheme from 'material-ui/styles/getMuiTheme';
    import MyAppRoot from './MyAppRoot';
    
    const muiTheme = getMuiTheme({
      datePicker: {
        selectColor: cyan500,
      },
    });
    
    class Main extends React.Component {
      render() {
        return (
          <MuiThemeProvider muiTheme={muiTheme}>
            <MyAppRoot />
          </MuiThemeProvider>
        );
      }
    }
    
    export default Main;
    
    0 讨论(0)
  • 2021-01-03 03:53

    If you are using the latest version of Material-UI, things changed. MuiThemeProvider and getMuiTheme are replaced by createMuiTheme and ThemeProvider respectively.

    You can use like this: import { createMuiTheme, ThemeProvider } from '@material-ui/core/styles';

    Now Material-UI is using tree-shaking mechanism to avoid unnecessary bundles, so destructing is well to go.

    To change the header, use something like this:

    const muiTheme = createMuiTheme({
        overrides: {
            MuiPickersToolbar: {
                toolbar: { backgroundColor: 'var(--themeP)' }
            },
    
    ...
    
    
    0 讨论(0)
提交回复
热议问题