DEV Community

Dhiman_aman
Dhiman_aman

Posted on

3

Create React page with Dark mode using Material UI

Prerequisite

  • Material UI Install
  • React APP Installation

Let's Starts

First install the MUI material
for npm
npm install @mui/material @emotion/react @emotion/styled

or for yarn

yarn add @mui/material @emotion/react @emotion/styled

In App.js

  • Import the file from mui/material
    Image description

  • createTheme use to set the theme

  • ThemeProvider use to set the theme

  • use Create theme
    let theme = createTheme({
    palette: {
    mode: "dark",
    },
    });

then in the return function App()
<ThemeProvider theme={theme}>
<Table />
</ThemeProvider>

  • Final, use CssBaseline from @mui/material

Adding inside of the component will also enable dark mode for the app's background.

<ThemeProvider theme={theme}>
<CssBaseline />
<main>Hello this is testing</main>
</ThemeProvider>

All Sets, Let Run the App

npm start

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay