AI CSS Animations

Bounce In Tooltip

The bell rings and a tooltip bounces up out of it, squashing as it lands. One keyframe animation plays each time it opens, with the scale anchored at the arrow.

Also known as: bouncing tooltip css, tooltip bounce animation, notification bell tooltip.

You're all caught up

HTML

<span class="tip-bounce-in">
  <button type="button" aria-label="Notifications" aria-describedby="tip-bounce-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="M6 9.5a6 6 0 0 1 12 0c0 5.5 2.5 7.5 2.5 7.5h-17S6 15 6 9.5z"/><path d="M10.2 20.5a2 2 0 0 0 3.6 0"/></svg></button>
  <span class="tip-bounce-in-tip" id="tip-bounce-in-tip" role="tooltip">You're all caught up</span>
</span>

CSS

.tip-bounce-in {
  --c: var(--tip-color, #3b82f6);
  font-size: var(--tip-size, 16px);
  position: relative;
  display: inline-flex;
}
.tip-bounce-in button {
  display: grid;
  place-items: center;
  width: 2.7em;
  height: 2.7em;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--c) 8%, transparent);
  color: var(--c);
  cursor: pointer;
}
.tip-bounce-in svg {
  width: 1.3em;
  height: 1.3em;
  transform-origin: 50% 0.2em;
}
.tip-bounce-in:hover svg { animation: tip-bounce-in-ring 0.7s ease-in-out; }
.tip-bounce-in button:focus-visible {
  outline: 2px solid var(--c);
  outline-offset: 2px;
}
.tip-bounce-in-tip {
  position: absolute;
  bottom: calc(100% + 0.75em);
  left: 50%;
  z-index: 10;
  padding: 0.45em 0.85em;
  border-radius: 0.5em;
  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;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
}
.tip-bounce-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-bounce-in:hover .tip-bounce-in-tip,
.tip-bounce-in:focus-within .tip-bounce-in-tip {
  opacity: 1;
  visibility: visible;
  animation: tip-bounce-in-pop 0.7s cubic-bezier(0.25, 0.7, 0.35, 1) both;
}
@keyframes tip-bounce-in-pop {
  0% { opacity: 0; transform: translate(-50%, 1em) scale(0.4); }
  40% { opacity: 1; transform: translate(-50%, -0.5em) scale(0.95, 1.08); }
  62% { transform: translate(-50%, 0) scale(1.1, 0.88); }
  80% { transform: translate(-50%, -0.12em) scale(0.98, 1.03); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes tip-bounce-in-ring {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(16deg); }
  40% { transform: rotate(-12deg); }
  60% { transform: rotate(7deg); }
  80% { transform: rotate(-3deg); }
}

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