const EL = (sel, par) => (par||document).querySelector(sel);
EL("#toggle").addEventListener("click", () => {
EL("#menu").classList.toggle("is-open");
});
/* QuickReset */
* {
margin: 0;
box-sizing: border-box;
}
#toggle {
position: fixed;
right: 0;
padding: 1rem;
/* hopefully you know how to style a Button */
}
#menu {
position: fixed;
padding: 30px;
width: calc(100vw - 100px); /* or whatever you want, does not matters */
height: 100vh;
background: gold;
transition: transform 0.5s; /* transition property and duration */
transform: translateX(-100%); /* -100% of self-width (hidden) */
}
#menu.is-open {
transform: translateX(0%); /* (visible) */
}
<div id="menu">I am something that actually toggles</div>
<button type="button" id="toggle">Toggle</button>