Skip to content
IndexRequest a UIAboutContact

Shake Error Feedback

A form field that shakes briefly and shows a clear message when the input is invalid, with a no-motion fallback.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Clean UI mockup of a sign-in form with an email field marked invalid: red border, a small red warning icon inside the field, a red message below reading Enter a valid email like [email protected], subtle motion lines at both sides of the field suggesting a short horizontal shake, a primary Continue button under it, light theme, flat modern style. Negative: heavy shadows, clutter, text errors, device frames. Reduced motion: static design.

About this pattern

Definition

A quick horizontal shake says no, like shaking your head. It draws the eye to the field that needs attention. It must never be the only signal: the field also needs a red border, an icon or text, and a message that explains how to fix the problem.

Purpose & UX principles

  • Shake along the x axis for about 300ms with three to four small steps of 4 to 8 pixels.
  • Add aria-invalid and connect the message with aria-describedby.
  • Move focus to the field so keyboard users land on the problem.
  • Re-trigger the animation by removing and re-adding the class.

Interaction states

  • Enter an email and press Submit; try empty, invalid and valid values.

Motion specification

  • The shake lasts 300ms.
  • Reduced motion: no shake; the border flashes once instead.

Responsive behaviour

  • Under reduced motion, skip the shake and rely on the border and text.
  • Do not shake on every keystroke; validate on submit or on blur.

Code

HTML
<div class="bx"><form id="fm" novalidate><label class="fl" for="em">Email</label><input id="em" type="email" autocomplete="off" placeholder="[email protected]" aria-describedby="er"><p class="er" id="er" role="alert"></p><button class="mini" type="submit">Continue</button></form><label class="sw"><input id="sk" type="checkbox" checked> Shake animation</label></div>

Related patterns

Validation States

↗
Validation StatesInputs & Forms

Form Error Summary

↗
Form Error SummaryFeedback & Notifications

Press Feedback

↗
Press FeedbackButtons & Actions