JSFiddle - React, Tailwind, and code Playground

by Austin Anderson

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="wrapper">
  <div id="button">
    <p>Option One</p>
    <i class="fa fa-chevron-down" aria-hidden="true"></i>
  </div>
  <div id="dropdown">
    <ul id="content">
      <li><a href="#">Option One</a></li>
      <li><a href="#">Option Two</a></li>
      <li><a href="#">Option Three</a></li>
      <li><a href="#">Option Four</a></li>
      <li><a href="#">Option Five</a></li>
    </ul>
  </div>
</div>

CSS

body {
  font-family: 'Open Sans', sans-serif;
  backface-visibility: hidden;
}

.wrapper {
  margin: 0 auto;
  width: 210px;
  border: solid 1px black;
  border-radius: 5px;
  background: white;
  font-size:16px;
}

.wrapper * {
  user-select: none;
}

#button {
  position: relative;
  top: 4px;
  left: 0;
  width: 200px;
  height: 35px;
  margin: 0;
  padding: 0 5px 0 5px;
  border-radius: 5px;
  cursor: pointer;
}

#button i {
  position: absolute;
  top: 7px;
  right: 10px;
}

#button p {
  text-align: center;
  font-weight: 200;
  letter-spacing: 2px;
  line-height: 36px;
  color: black;
  margin-top: -4px;
}

#dropdown {
  position: relative;
  top: 0px;
  left: 0;
  width: 200px;
  height: 0;
  margin: 0;
  padding: 0 5px 5px 5px;
  border-radius: 0 0 5px 5px;
  background: white;
  transition: 0.5s;
  cursor: pointer;
  overflow: hidden;
}

#content {
  list-style: none;
  margin: 0;
  padding: 5px 5px 0 5px;
  opacity: 0;
}

#content li {
  margin: 0 0 5px 0;
  padding: 0 0 10px 0;
  width: 100%;
}

#content li a {
  text-decoration: none;
  margin: 0 0 5px 0;
  padding: 0;
  font-weight: 100;
  letter-spacing: 2px;
  color: black;
}

JavaScript

(function() {
  "use strict";

  var dropdown = document.getElementById('dropdown'),
    content = document.getElementById('content'),
    button = document.getElementById('button');

  button.onclick = function() {

    if (dropdown.style.height === "100%") {
      dropdown.style.height = "0";
      content.style.opacity = "0";

    } else {
      dropdown.style.height = "100%";
      dropdown.style.transition = "height 0.5s";
      content.style.transition = "opacity 0.5s";
      content.style.opacity = "1";
    }

  };
})();