JSFiddle - React, Tailwind, and code Playground

by Alexandru Gatea

HTML

<div class="floating-controls">
  <div class="control-group">
    <button data-tooltip="Something explicit">O</button>
  </div>
  <div class="control-group">
    <button>O</button>
  </div>
  <div class="control-group">
    <button>O</button>
  </div>
  <div class="control-group">
    <button data-tooltip="Hey there">O</button>
    <button data-tooltip="I do nothing">O</button>
    <button data-tooltip="Press me">O</button>
  </div>
</div>

SCSS

* {
  box-sizing: border-box;
}


@mixin flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}


button {
  width: 4rem;
  height: 3rem;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  border: none;
  background: #000;
  color: #fff;
  margin: 0;
  border-radius: 0px;
  cursor: pointer;
}


.floating-controls {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  @include flex-center;

  .control-group {
    margin: 0 0.25rem;

    @include flex-center;

    button:first-of-type {
      border-top-left-radius: 0.25rem;
      border-bottom-left-radius: 0.25rem;
    }

    button:last-of-type {
      border-top-right-radius: 0.25rem;
      border-bottom-right-radius: 0.25rem;
    }
  }
}

[data-tooltip] {
  position: relative;
  z-index: 0;

  &:before {
    content: attr(data-tooltip);
    display: flex;
    align-items: flex-end;
		justify-content: center;
    max-width: 40rem;
		min-width: 5rem;
    padding: 0.5rem;
		text-align: center;


    position: absolute;
    bottom: calc(100% + 1rem);
    left: 50%;
    transform: translate(-50%, -0.5rem);

    background: #000;
    color: #fff;
    font-weight: 400;
    font-size: 1rem;
    border-radius: 0.25rem;

    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 2;
  }

  &:after {
    content: "";
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 10px 10px 0 10px;
    border-color: #000 transparent transparent transparent;
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 50%;
    transform: translate(-50%, -0.5rem);
    z-index: 1;
    opacity: 0;
    pointer-events: 0;
		transition: all 0.3s ease;
  }

  &:hover:before {
    opacity: 1;
    transform: translate(-50%, 0);
  }

  &:hover:after {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}