mui-themex
TypeScript icon, indicating that this package has built-in type declarations

1.1.7 • Public • Published

Use

import {withThemex, useThemex, toggleTheme, isDarkMode} from 'mui-themex'
import {ThemeProvider} from '@mui/material/styles';
import CssBaseline from "@mui/material/CssBaseline"
import { Button, Box } from '@mui/material';


const Child = () => {
  return <Box bgcolor="background.paper">
    <Button onClick={toggleTheme}>Toggle Theme</Button>
  </Box>
}

const App = ({theme}) => {
  
  return (
      <ThemeProvider theme={theme}>
        <CssBaseline />
        <Child />
        <Box bgcolor="background.paper">
          <Button onClick={toggleTheme}>Toggle Theme</Button>
        </Box>
      </ThemeProvider>
  );
};

export default withThemex(App, 'light', (theme) => ({}))

WithThemex

withThemex(ComponentType, defaultMode, customize)
ComponentType

React component

defaultMode
Callback or 'dark' | 'light'

callback: () => 'dark' | 'light'
customize
Customize the theme.

argument type: callback | object

callback: (oldTheme) => material ui theme object
object: material ui theme object

AutoSave

Just add Property in the customize option

{
  autoSave: true
}

Readme

Keywords

none

Package Sidebar

Install

npm i mui-themex

Weekly Downloads

2

Version

1.1.7

License

MIT

Unpacked Size

146 kB

Total Files

38

Last publish

Collaborators

  • devnax