AI CSS Animations

Blur In Tooltip

The tooltip comes into focus: it starts large and blurred and settles sharp above the button, like a camera pulling focus. Animates filter: blur() together with a scale.

Also known as: blur tooltip css, focus in tooltip animation, zoom blur tooltip.

Opens in a new tab

HTML

<span class="tip-blur-in">
  <button type="button" aria-describedby="tip-blur-in-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="M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12z"/><circle cx="12" cy="12" r="3"/></svg>Preview</button>
  <span class="tip-blur-in-tip" id="tip-blur-in-tip" role="tooltip">Opens in a new tab</span>
</span>

CSS

.tip-blur-in {
  --c: var(--tip-color, #3b82f6);
  font-size: var(--tip-size, 16px);
  position: relative;
  display: inline-flex;
}
.tip-blur-in button {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.6em 1.2em;
  border: 0;
  border-radius: 0.5em;
  background: var(--c);
  color: #fff;
  font: 600 1em system-ui, sans-serif;
  cursor: pointer;
}
.tip-blur-in svg {
  width: 1.2em;
  height: 1.2em;
}
.tip-blur-in button:focus-visible {
  outline: 2px solid var(--c);
  outline-offset: 2px;
}
.tip-blur-in-tip {
  position: absolute;
  bottom: calc(100% + 0.75em);
  left: 50%;
  z-index: 10;
  padding: 0.45em 0.8em;
  border-radius: 0.45em;
  background: color-mix(in srgb, var(--c) 14%, #0f172a);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.07), 0 0.5em 1em -0.4em rgb(0 0 0 / 0.5);
  color: #fff;
  font: 500 0.85em/1.3 system-ui, sans-serif;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  filter: blur(0.35em);
  transform-origin: 50% 100%;
  transform: translateX(-50%) scale(1.25);
  transition: opacity 0.25s ease, filter 0.35s ease, transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.4s;
}
.tip-blur-in-tip::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 0.6em;
  height: 0.6em;
  background: inherit;
  transform: translate(-50%, -50%) rotate(45deg);
}
.tip-blur-in:hover .tip-blur-in-tip,
.tip-blur-in:focus-within .tip-blur-in-tip {
  opacity: 1;
  visibility: visible;
  filter: blur(0);
  transform: translateX(-50%) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .tip-blur-in, .tip-blur-in *, .tip-blur-in::before, .tip-blur-in::after, .tip-blur-in *::before, .tip-blur-in *::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