<div id="root">
</div>
* {
  box-sizing: border-box;
  margin: 0;
  font-family: sans-serif;
}

.page {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  width: 100%;
  height: 80px;
  border-bottom: 2px solid gray;
  display: flex;
  justify-content: center;
  align-items: center;
}

.content {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 30px;
}

.footer {
  width: 100%;
  height: 80px;
  border-top: 2px solid gray;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.button {
  padding: 10px;
  margin-right: 30px;
}
const { useState } = React

const App = () => {
  const [isDark, setIsDark] = useState(false)
  return <Page isDark={isDark} setIsDark={setIsDark} />
}


  

function Page({isDark, setIsDark}) {
  return (
    <div>
      <Header isDark={isDark}/>
      <Content isDark={isDark} />
      <Footer isDark={isDark} setIsDark={setIsDark}/>
    </div>
  )
}


function Header({isDark}) {
  return (
    <header
      className="header" style={{ backgroundColor: isDark ? "black" : "lightgray", color: isDark ? "white" : "black" }}>
      <h1>Welcome 곽튜브</h1>
    </header>
  )
}

function Content({isDark}) {
  return (
    <div className="content" style={{ backgroundColor: isDark ? "black" : "white", color: isDark ? "white" : "black", }} >
      <p>곽튜브님, 좋은 여행 되세요.</p>
    </div>
  )
}

function Footer({isDark, setIsDark}) {
  const toggleTheme = () => {
    setIsDark(!isDark)
  }
  return (
    <footer className="footer" style={{ backgroundColor: isDark ? "black" : "lightgray" }} >
      <button className="button" onClick={toggleTheme}>
        Dark Mode
      </button>
    </footer>
  )
}

ReactDOM.render(<App />,
document.getElementById("root"))
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js