JSFiddle - React, Tailwind, and code Playground

by Sebastian Kay

HTML

<div class="tooltip">Hover over me
  <span class="tooltiptext">Tooltip text</span>
</div>

CSS

.tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted black;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 120px;
  background-color: #000;
  color: #fff;
  text-align: center;
  border-radius: 0.2rem;
  padding: 5px 0;
  position: absolute;
  z-index: 1;
  top: 135%;
  left: 50%;
  margin-left: -60px;
  opacity: 0;
  transition: opacity 0.3s;
}

.tooltip .tooltiptext::after {
  content: "";
  position: absolute;
  top: -35%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent #000 transparent;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}