JSFiddle - React, Tailwind, and code Playground

by ethanpil

HTML

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
<nav>
  <div class='menubutton'>
    <input type='checkbox' id='menubuttoninput'>
    <label for='menubuttoninput'>
      <i class="fa-solid fa-bars not-active"></i>
      <i class="fa-solid fa-xmark active"></i>
    </label>
  </div>
  This is a navbar!
</nav>

<div class='container'>
  <div class='container-left'>
    Left
  </div>
  <div class='container-right'>
    right
  </div>
</div>

CSS

/* reset */
body {
  margin: 0;
}
* {
  box-sizing: border-box;
}


nav {
  display: flex;
  width: 100%;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background-color: purple;
  color: white;
}


/*the menu button is basically a hidden check box, we use label to style it as a button */

.menubutton>input {
  display: none;
}




.container {
  display: flex;
  width: 100%;
}

.container-left {
  background-color: plum;
  height: 50vh;
  padding: 0.5rem 0.5rem;
  border: 1px solid transparent;
  width: 3rem;
  transition: width 300ms;
}

.container-right {
  border: 1px solid lightgray;
  height: 50vh;
  flex-grow: 1;
  padding: 0.5rem 0.5rem;
}

/* this is the bit that styles the width of the sidebar when the checkbox is checked. */




/* just style the right box for visibility */