@mui/material/styles#createTheme JavaScript Examples

The following examples show how to use @mui/material/styles#createTheme. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Theme.js    From FSE-Planner with MIT License 6 votes vote down vote up
Theme = createTheme({
  palette: {
    primary: {
      main: '#3f51b5'
    },
    secondary: {
      main: '#f50057'
    },
    error: {
      main: '#f44336'
    },
    warning: {
      main: '#ff9800'
    },
    info: {
      main: '#2196f3'
    },
    success: {
      main: '#4caf50'
    },
  },
  components: {
    MuiLink: {
      defaultProps: {
        underline: 'hover',
      },
    },
  },
})
Example #2
Source File: index.js    From Django-REST-Framework-React-BoilerPlate with MIT License 6 votes vote down vote up
export default function ThemeProvider({ children }) {
  const themeOptions = useMemo(
    () => ({
      palette,
      shape: { borderRadius: 8 },
      typography,
      shadows,
      customShadows,
    }),
    []
  );

  const theme = createTheme(themeOptions);
  theme.components = componentsOverride(theme);

  return (
    <StyledEngineProvider injectFirst>
      <MUIThemeProvider theme={theme}>
        <CssBaseline />
        {children}
      </MUIThemeProvider>
    </StyledEngineProvider>
  );
}
Example #3
Source File: muiSetup.js    From Edlib with GNU General Public License v3.0 6 votes vote down vote up
muiTheme = createTheme({
    palette: {
        grey: {
            main: grey[300],
            dark: grey[400],
        },
        primary: {
            main: '#21456A',
            dark: '#21456A',
        },
        secondary: {
            main: '#82E066',
            dark: '#1D7105',
        },
    },
    typography: {
        htmlFontSize: 16,
        fontFamily: "'Lato', sans-serif",
    },
})
Example #4
Source File: theme.js    From karto with MIT License 5 votes vote down vote up
theme = createTheme({
    palette: {
        mode: 'dark',
        primary: {
            main: '#EC5E69',
            dark: '#65282d'
        },
        secondary: {
            main: '#5893DF',
            dark: '#294468'
        },
        warning: {
            main: '#ff9800',
            dark: '#5f3b00'
        },
        background: {
            paper: '#24344D',
            default: '#192231'
        }
    },
    typography: {
        h1: {
            fontSize: '2rem'
        },
        h2: {
            fontSize: '1.2rem'
        },
        body1: {
            fontSize: '0.8rem'
        },
        body2: {
            fontSize: '0.7rem'
        },
        button: {
            fontSize: '0.65rem'
        }
    },
    components: {
        MuiButton: {
            styleOverrides: {
                root: {
                    minWidth: 0
                }
            }
        }
    }
})
Example #5
Source File: app-wrapper.js    From neutron with Mozilla Public License 2.0 5 votes vote down vote up
AppWrapper = ({ children }) => {
  const isFullScreen = useSelector((state) => state.general.isFullScreen);
  const locked = useSelector((state) => window.mode !== 'about' && state.general.locked);
  const shouldUseDarkColors = useSelector((state) => state.general.shouldUseDarkColors);

  const themeObj = {
    typography: {
      fontFamily: '"Roboto",-apple-system,BlinkMacSystemFont,"Segoe UI",Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif',
      fontSize: 13.5,
    },
    palette: {
      mode: shouldUseDarkColors ? 'dark' : 'light',
      primary: {
        light: blue[300],
        main: blue[600],
        dark: blue[800],
      },
      secondary: {
        light: red[300],
        main: red[500],
        dark: red[700],
      },
      // config taken from MUI V4
      background: shouldUseDarkColors ? {
        paper: '#424242',
        default: '#303030',
      } : {
        paper: '#fff',
        default: '#fafafa',
      },
    },
  };

  if (!shouldUseDarkColors) {
    themeObj.background = {
      primary: grey[200],
    };
  }

  const theme = createTheme(themeObj);

  const showWindowsTitleBar = window.process.platform !== 'darwin' && !isFullScreen && !getStaticGlobal('useSystemTitleBar');

  return (
    <StyledEngineProvider injectFirst>
      <MuiThemeProvider theme={theme}>
        <LocalizationProvider dateAdapter={AdapterDateFns}>
          <CssBaseline />
          <div
            style={{
              height: '100vh',
              width: '100vw',
              overflow: 'hidden',
            }}
          >
            {showWindowsTitleBar && <WindowsTitleBar title={window.mode !== 'main' ? document.title : undefined} />}
            <div style={{ height: showWindowsTitleBar ? 'calc(100vh - 32px)' : '100vh' }}>
              {locked ? <AppLock /> : children}
            </div>
          </div>
        </LocalizationProvider>
      </MuiThemeProvider>
    </StyledEngineProvider>
  );
}
Example #6
Source File: sampleComponent.jsx    From redis-examples with MIT License 5 votes vote down vote up
darkTheme = createTheme({
  palette: {
    primary: {
      main: orange[400],
    },
  }
})
Example #7
Source File: sampleComponent.jsx    From redis-examples with MIT License 5 votes vote down vote up
lightTheme = createTheme({
  palette: {
    primary: {
      main: grey[400],
    },
  }
})
Example #8
Source File: App.js    From material-ui-color with MIT License 5 votes vote down vote up
theme = createTheme({
  palette: {}
})
Example #9
Source File: index.js    From mui-image with ISC License 5 votes vote down vote up
theme = createTheme({
	typography: {
		fontFamily: ['Fira Code', 'monospace'].join(','),
	},
	palette: {
		primary: { main: '#2979ff' },
	},
})
Example #10
Source File: App.js    From sampo-ui with MIT License 5 votes vote down vote up
defaultTheme = createTheme()
Example #11
Source File: index.js    From react-material-workspace-layout with MIT License 5 votes vote down vote up
theme = createTheme()
Example #12
Source File: index.js    From react-material-workspace-layout with MIT License 5 votes vote down vote up
theme = createTheme()
Example #13
Source File: index.js    From react-material-workspace-layout with MIT License 5 votes vote down vote up
theme = createTheme()
Example #14
Source File: index.js    From react-material-workspace-layout with MIT License 5 votes vote down vote up
theme = createTheme()
Example #15
Source File: index.js    From react-material-workspace-layout with MIT License 5 votes vote down vote up
theme = createTheme()
Example #16
Source File: index.js    From react-material-workspace-layout with MIT License 5 votes vote down vote up
theme = createTheme()
Example #17
Source File: index.js    From react-material-workspace-layout with MIT License 5 votes vote down vote up
theme = createTheme()
Example #18
Source File: theme.js    From admin-web with GNU Affero General Public License v3.0 4 votes vote down vote up
theme = createTheme({
  components: {
    MuiFormControlLabel: {
      styleOverrides: {
        root: {
          color: mode === 'light' ? '#333' : '#fff',
        },
      },
    },
    MuiPaper: {
      styleOverrides: {
        elevation1: {
          borderRadius: 8,
          margin: 16,
          boxShadow: mode === 'light' ? '0px 3px 3px -2px rgba(0, 0, 0, 0.06),0px 3px 4px 0px rgba(0, 0, 0, 0.042),0px 1px 8px 0px rgba(0, 0, 0, 0.036)' : '0 0 1px 0 rgba(0,0,0,0.70), 0 3px 4px -2px rgba(0,0,0,0.50)',
        },
      },
    },
    MuiAppBar: {
      styleOverrides: {
        colorPrimary: {
          backgroundColor: mode === 'light' ? '#fff' : blue[600],
          color: mode === 'light' ? '#333' : '#fff',
          boxShadow: '0px 5px 5px -3px rgba(0, 0, 0, 0.06),0px 8px 10px 1px rgba(0, 0, 0, 0.042),0px 3px 14px 2px rgba(0, 0, 0, 0.036)',
        },
      },
    },
    MuiChip: {
      styleOverrides: {
        colorSecondary: {
          backgroundColor: red['500'],
          color: '#000',
        },
        colorPrimary: {
          backgroundColor: blue['300'],
          color: '#000',
        },
      },
    },
    MuiTableCell: {
      styleOverrides: {
        head: {
          height: '30px',
          padding: '10px 16px',
        },
        body: {
          height: '40px',
          border: 'none',
        },
      },
    },
    MuiTableRow: {
      styleOverrides: {
        hover: {
          '&:hover': {
            backgroundColor: '#ddd',
            cursor: 'pointer',
          },
        },
        root: {
          '&:nth-of-type(even)': {
            backgroundColor: mode === 'light' ? '#eee' : '#202329',
          },
        },
      },
    },
    MuiButton: {
      styleOverrides: {
        contained: {
          boxShadow: '0px 5px 5px -3px rgba(0, 0, 0, 0.06), 0px 8px 10px 1px rgba(0, 0, 0, 0.042), 0px 3px 14px 2px rgba(0, 0, 0, 0.036)',
      
          '&.Mui-disabled': {
            background: 'linear-gradient(#e0e0e0, #e0e0e0)',
            color: '#999',
          },
        },
        containedPrimary: {
          background: 'linear-gradient(150deg, #56CCF2, #2F80ED)',
        },
        containedSecondary: {
          background: 'linear-gradient(150deg, #FF512F, #DD2476)',
          color: '#fff',
        },
      },
    },
    MuiGridListTile: {
      styleOverrides: {
        tile: {
          display: 'flex',
          flex: 1,
        },
      },
    },
    MuiTooltip: {
      styleOverrides: {
        tooltip: {
          fontSize: 14,
        },
      },
    },
    MuiTab: {
      styleOverrides: {
        root: {
          color: mode === 'light' ? '#333' : '#ddd',
        },
      },
    },
  },
  typography: {
    h1: {
      color: mode === 'light' ? '#333' : '#fff',
      fontSize: '2em',
      fontWeight: 'bold',
    },
    h2: {
      color: mode === 'light' ? '#333' : '#fff',
      fontSize: '1.5em',
      fontWeight: 'bold',
    },
    caption: {
      color: mode === 'light' ? '#000' : '#fff',
    },
  },
  palette: {
    mode: mode,
    text: {
      primary: mode === 'light' ? '#000' : '#fff',
    },
    primary: blue,
    secondary: grey,
  },
})
Example #19
Source File: App.js    From sampo-ui with MIT License 4 votes vote down vote up
theme = createTheme({
  palette: {
    primary: {
      main: colorPalette.primary.main
    },
    secondary: {
      main: colorPalette.secondary.main
    }
  },
  breakpoints: {
    values: {
      ...muiDefaultBreakpoints,
      reducedHeight: reducedHeightBreakpoint,
      hundredPercentHeight: hundredPercentHeightBreakPoint
    }
  },
  components: {
    MuiToolbar: {
      styleOverrides: {
        regular: {
          [defaultTheme.breakpoints.down(reducedHeightBreakpoint)]: {
            minHeight: topBar.reducedHeight
          },
          [defaultTheme.breakpoints.up(reducedHeightBreakpoint)]: {
            minHeight: topBar.defaultHeight
          }
        }
      }
    },
    MuiCircularProgress: {
      defaultProps: {
        thickness: 5
      }
    },
    MuiIconButton: {
      styleOverrides: {
        root: {
          padding: 4
        }
      }
    },
    MuiTooltip: {
      styleOverrides: {
        tooltip: {
          fontSize: '1rem'
        }
      }
    },
    MuiAccordion: {
      styleOverrides: {
        root: {
          '&.Mui-expanded': {
            marginTop: 8,
            marginBottom: 8
          }
        }
      }
    },
    MuiAccordionSummary: {
      styleOverrides: {
        root: {
          paddingLeft: 8,
          paddingRight: 8,
          minHeight: 40
        },
        content: {
          marginTop: 4,
          marginBottom: 4,
          '&.Mui-expanded': {
            marginTop: 0,
            marginBottom: 0
          }
        }
      }
    },
    MuiButton: {
      styleOverrides: {
        endIcon: {
          marginLeft: 0
        }
      }
    },
    MuiTableCell: {
      styleOverrides: {
        sizeSmall: {
          paddingTop: 0,
          paddingBottom: 0
        }
      }
    }
  }
})