I am trying to implement dark mode, and I thought the Paper component was needed from Material UI to do so. Anyway, I've been having problems since it's doing the opposite: it won't work with Paper, and I cannot even remove it since other Material UI components use it. The only "fix" I found is applying
.MuiPaper-root {
  color: unset !important;
  background-color: unset !important;
}
to the Paper component, which doesn't solve anything since it then messes with other components. Am I missing something? This is my _app.js
    <StyledEngineProvider injectFirst>
        <ThemeProvider theme={theme}>
            <Provider store={store}>
                <Paper sx={{ marginLeft: '250px' }} elevation={0}>
                    <Layout onGetTheme={getTheme}>
                        <main>
                            <Head>
                                <title>page</title>
                                <link
                                    rel="stylesheet"
                                    href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
                                />
                                <meta
                                    name="viewport"
                                    content="initial-scale=1.0, width=device-width"
                                />
                            </Head>
                            <Component {...pageProps} />
                            <Footer></Footer>
                        </main>
                    </Layout>
                </Paper>
            </Provider>
        </ThemeProvider>
    </StyledEngineProvider>
Theme code
    const [darkMode, setDarkMode] = useState('light');
     const theme = useMemo(
    () =>
        createTheme({
            palette: {
                mode: darkMode,
            },
        }),
    [darkMode]
);
    const darkModeHandler = () => {
    setDarkMode(darkMode === 'light' ? 'dark' : 'light');
};
  
SCREENSHOTS
This is how it is:
This is how it should be: (these last ones work when I apply .MuiPaper-root { color: unset !important; background-color: unset !important; } which messes up other components



