AI CSS Animations

Bell Ring

A notification bell that rings in fast, shrinking swings from its top, with the clapper lagging the other way, then rests. The clapper pivots from a point above it via transform-box: fill-box.

Also known as: bell shake animation css, notification bell animation, ringing bell icon.

HTML

<div class="kfa-bell-ring"><svg class="kfa-bell-ring-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3.2V5M6 16.4V11a6 6 0 0 1 12 0v5.4l1.7 1.9H4.3Z" /><path class="kfa-bell-ring-clapper" d="M10 20.6a2 2 0 0 0 4 0" /></svg></div>

CSS

.kfa-bell-ring {
  --c: var(--kfa-color, #3b82f6);
  font-size: var(--kfa-size, 16px);
  display: grid;
  place-items: center;
  width: 5.5em;
  height: 5.5em;
  border-radius: 1em;
  background: var(--c);
  color: #fff;
  font-family: system-ui, sans-serif;
  font-weight: 700;
  box-shadow: 0 0.6em 1.4em -0.6em color-mix(in srgb, var(--c) 70%, transparent);
  transform-origin: 50% 12%;
  animation: kfa-bell-ring-swing 2.2s ease-in-out infinite;
}
.kfa-bell-ring-icon {
  width: 2.6em;
  height: 2.6em;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.kfa-bell-ring-clapper {
  transform-box: fill-box;
  transform-origin: 50% -200%;
  animation: kfa-bell-ring-clapper 2.2s ease-in-out infinite;
}
@keyframes kfa-bell-ring-swing {
  0%, 34%, 100% { transform: rotate(0); }
  3% { transform: rotate(16deg); }
  7% { transform: rotate(-14deg); }
  11% { transform: rotate(11deg); }
  15% { transform: rotate(-8deg); }
  19% { transform: rotate(5.5deg); }
  23% { transform: rotate(-3.5deg); }
  27% { transform: rotate(1.5deg); }
}
@keyframes kfa-bell-ring-clapper {
  0%, 38%, 100% { transform: rotate(0); }
  5% { transform: rotate(-26deg); }
  9% { transform: rotate(22deg); }
  13% { transform: rotate(-17deg); }
  17% { transform: rotate(12deg); }
  21% { transform: rotate(-8deg); }
  25% { transform: rotate(5deg); }
  30% { transform: rotate(-2deg); }
}

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

Customizing this snippet

  • Color: set --kfa-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --kfa-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 keyframe animations