JSFiddle - React, Tailwind, and code Playground

HTML

<button id="trigger" class="btn primary">Open modal</button>
<div id="theModal" class="cd-box modal bg">
  <div class="modal-content">
    <div class="title">
      <h3>Title</h3>
    </div>
    <span class="close">&times;</span>
    <div class="inside">
      <p>This is some content that goes into the modal. The width adjusts according to the content.</p>
    </div>
    <div class="buttons">
      <button class="btn secondary">Exit</button>
      <button class="btn primary">Continue with action</button>
    </div>
  </div>
</div>

CSS

body {font-family: Arial, Helvetica, sans-serif;}

/* The Modal (background) */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    padding-top: 100px; /* Location of the box */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

/* Modal Content */
.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
}

/* The Close Button */
.close {
    color: #aaaaaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

JavaScript

var modal = document.getElementById("theModal");
var btn = document.getElementById("trigger");
var span = document.getElementsByClassName("close")[0];
btn.onclick = function() {
    modal.style.display = "block";
}

span.onclick = function() {
    modal.style.display = "none";
}

window.onclick = function(event) {
  if (event.target == modal) {
    modal.display.style = "none";
  }
}