JSFiddle - React, Tailwind, and code Playground
CSS
.NavigationButton {
background-color:rgb(33,34,32);
width:64px;
height:64px;
border-radius:32px;
position:fixed;
bottom:20px;
right:20px;
border:none;
outline:none;
color:white;
-webkit-transition: width 0.3s, right 0.3s, border-radius 0.6s; /* Safari */
transition: width 0.3s, right 0.3s, border-radius 0.6s;
}
.NavigationButton:hover {
cursor:pointer;
}
.NavigationButtonToggled {
width:500px;
right:20px;
}
.NavigationButtonBurger1 {
position:absolute;
top:calc(50% - 10px);
left:32px;
transform:translate(-50%,-50%);
width:30px;
height:4px;
background-color:white;
-webkit-transition: all 0.4s; /* Safari */
transition: all 0.4s;
}
.NavigationButtonBurger2 {
position:absolute;
top:50%;
left:32px;
transform:translate(-50%,-50%);
width:30px;
height:4px;
background-color:white;
-webkit-transition: all 0.4s; /* Safari */
transition: all 0.4s;
}
.NavigationButtonBurger3 {
position:absolute;
top:calc(50% + 10px);
left:32px;
transform:translate(-50%,-50%);
width:30px;
height:4px;
background-color:white;
-webkit-transition: all 0.3s; /* Safari */
transition: all 0.3s;
}
.NavigationButtonToggled .NavigationButtonBurger2 {
opacity:0;
left:0px;
width:20px;
}
.NavigationButtonToggled .NavigationButtonBurger1 {
left:32px;
top:50%;
transform:translate(10px,-2px) rotate(45deg);
width:20px;
}
.NavigationButtonToggled .NavigationButtonBurger3 {
left:32px;
top:50%;
transform:translate(10px,-2px) rotate(-45deg);
width:20px;
}
.NavigationButtonToggled p {
display:none;
}
.NavigationButtonToggled ul {
display:block !important;
height:100px;
}
.NavigationButton ul {
display:none;
list-style-type: none;
margin: 0;
padding: 0;
margin-left:100px;
overflow: hidden;
background-color: rgba(0,0,0,0);
height:100%;
width:calc(100% - 100px);
border-top-right-radius:32px;
border-bottom-right-radius:32px;
}
.NavigationButton li {
float: left;
width:33.3333333%;
...
JavaScript
var navigationButton = document.getElementById("NavigationButton");
var navigationToggled = true;
navigationButton.addEventListener("click", function() {
navigationToggled = !navigationToggled;
if (navigationToggled) {
navigationButton.classList.remove("NavigationButtonToggled");
} else {
navigationButton.classList.add("NavigationButtonToggled");
}
});