Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

mui how to set background in theme

import React from "react";
import ReactDOM from "react-dom";
import CssBaseline from "@mui/material/CssBaseline";
import { ThemeProvider, createTheme } from "@mui/material/styles";
import Button from "@mui/material/Button";

const themeLight = createTheme({
  palette: {
    background: {
      default: "#e4f0e2"
    }
  }
});

const themeDark = createTheme({
  palette: {
    background: {
      default: "#222222"
    },
    text: {
      primary: "#ffffff"
    }
  }
});

const App = () => {
  const [light, setLight] = React.useState(true);
  return (
    <ThemeProvider theme={light ? themeLight : themeDark}>
      <CssBaseline />
      <Button onClick={() => setLight((prev) => !prev)}>Toggle Theme</Button>
    </ThemeProvider>
  );
};

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
Comment

PREVIOUS NEXT
Code Example
Javascript :: get element by 
Javascript :: how to disable react in jsx scope eslint 
Javascript :: $(document).ready, window.onload 
Javascript :: redux logger 
Javascript :: invalid time value react datepicker 
Javascript :: how to reverse a string in javascript 
Javascript :: js dynamicly add script 
Javascript :: toggle hidden attribute javascript 
Javascript :: jquery ajax form submission 
Javascript :: vuetify change text color of radio button 
Javascript :: nodejs format text 
Javascript :: radio button in react 
Javascript :: You need to authorize this machine using `npm adduser` 
Javascript :: beautify json in html 
Javascript :: connecting react to socket.io 
Javascript :: USA phone number validator angular 
Javascript :: sort from the key value js 
Javascript :: jquery selector checked 
Javascript :: how to check if browser tab is active javascript 
Javascript :: remove axis tick ends d3 
Javascript :: refresh datatable on button click with maintaining paging 
Javascript :: use import in node 
Javascript :: react native new line character 
Javascript :: js select element by css selector 
Javascript :: javascript replace all occurrences of string 
Javascript :: iterate object js 
Javascript :: fibonacci javascript 
Javascript :: classlist.toggle 
Javascript :: js maximum number value 
Javascript :: settimeout inside loop 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =