Attention

Shake Animation

A horizontal shake for invalid form input and error states.

Edit this in the studio

Opens with this animation loaded. Nothing is uploaded — the scene travels in the link.

animation.css
.shake {
  transform: translate3d(165px, 137px, 0);
  width: 150px;
  height: 46px;
  background: #6366f1;
  border-radius: 999px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  animation: shake-anim 700ms linear 0ms infinite both;
  will-change: transform, opacity;
}

@keyframes shake-anim {
  0% {
    transform: translate3d(165px, 137px, 0);
    animation-timing-function: ease-in-out;
  }
  15% {
    transform: translate3d(153px, 137px, 0);
    animation-timing-function: ease-in-out;
  }
  30% {
    transform: translate3d(175px, 137px, 0);
    animation-timing-function: ease-in-out;
  }
  45% {
    transform: translate3d(157px, 137px, 0);
    animation-timing-function: ease-in-out;
  }
  60% {
    transform: translate3d(171px, 137px, 0);
    animation-timing-function: ease-in-out;
  }
  75% {
    transform: translate3d(161px, 137px, 0);
    animation-timing-function: ease-in-out;
  }
  100% {
    transform: translate3d(165px, 137px, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .shake {
    animation: none;
    transition: none;
  }
}

Why it is built this way

The amplitude decays across the keyframes so it settles rather than stopping dead. Because this usually signals an error, keep it under about 700ms and never loop it — a repeating shake reads as broken rather than as feedback.

What it animates

1 property across 1 CSS declaration. The bar shows when each one is moving.

X
transform
0 0px
7 stopscompositor

What it costs to run

X is handled by the compositor: no layout, no repaint, and the work can run off the main thread. This is the cheap end of CSS animation, which is why it stays smooth on a slow phone where other properties will not.

It runs for 0.70s across 7 keyframe stops, with every property moving over the same window.

One curve throughout: Ease In Out on a button. Keeping a single easing across every property is what makes a multi-property animation read as one movement rather than several things happening at once.

Accessibility

Nothing here hides content — x moves over 0.70s and the element is visible throughout. The exported prefers-reduced-motion guard still silences it, which matters most for the looping ones: motion that never stops is the kind that makes people feel unwell.

Related animations

shakeerrorformvalidation