AI CSS Animations

Bottom Tooltip With Arrow

A light tooltip that drops in below an icon button, with a white fill, a hairline border and an arrow that keeps the outline. The arrow is a square with only two borders.

Also known as: tooltip below css, light tooltip css, white tooltip with border.

Download PDF · 2.4 MB

HTML

<span class="tip-bottom-arrow">
  <button type="button" aria-label="Download" aria-describedby="tip-bottom-arrow-tip"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 4v11M7.5 10.5 12 15l4.5-4.5M5 19.5h14"/></svg></button>
  <span class="tip-bottom-arrow-tip" id="tip-bottom-arrow-tip" role="tooltip">Download PDF · 2.4 MB</span>
</span>

CSS

.tip-bottom-arrow {
  --c: var(--tip-color, #3b82f6);
  font-size: var(--tip-size, 16px);
  position: relative;
  display: inline-flex;
}
.tip-bottom-arrow button {
  display: grid;
  place-items: center;
  width: 2.6em;
  height: 2.6em;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  border-radius: 0.6em;
  background: color-mix(in srgb, var(--c) 10%, transparent);
  color: var(--c);
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.tip-bottom-arrow svg {
  width: 1.25em;
  height: 1.25em;
}
.tip-bottom-arrow:hover button { background: color-mix(in srgb, var(--c) 20%, transparent); }
.tip-bottom-arrow button:focus-visible {
  outline: 2px solid var(--c);
  outline-offset: 2px;
}
.tip-bottom-arrow-tip {
  position: absolute;
  top: calc(100% + 0.75em);
  left: 50%;
  z-index: 10;
  padding: 0.45em 0.75em;
  border: 1px solid rgb(15 23 42 / 0.14);
  border-radius: 0.45em;
  background: #fff;
  box-shadow: 0 0.6em 1.2em -0.5em rgb(15 23 42 / 0.35);
  color: #1e293b;
  font: 500 0.85em/1.3 system-ui, sans-serif;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, -0.4em);
  transition: opacity 0.18s ease, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.25s;
}
/* a square with only its top and left borders, turned 45deg, continues the outline */
.tip-bottom-arrow-tip::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  box-sizing: border-box;
  width: 0.7em;
  height: 0.7em;
  border: inherit;
  border-right: 0;
  border-bottom: 0;
  border-radius: 0.12em 0 0;
  background: inherit;
  transform: translate(-50%, 55%) rotate(45deg);
}
.tip-bottom-arrow:hover .tip-bottom-arrow-tip,
.tip-bottom-arrow:focus-within .tip-bottom-arrow-tip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  .tip-bottom-arrow, .tip-bottom-arrow *, .tip-bottom-arrow::before, .tip-bottom-arrow::after, .tip-bottom-arrow *::before, .tip-bottom-arrow *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --tip-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --tip-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar tooltips