04.21 · Micro-Interactions
Error Shake
A field shakes side to side when the input is wrong. Best for sign-in forms.
Click it
Sign in with a wrong or empty password (the right one is letmein), or press Show me.
Inside, the zig-zag is the field's path, drawn five times as wide: each swing is smaller than the last, and it ends where it started. Sign in with a wrong password, or press Show me.
Just turns red only changes the border and message, which is easy to miss; Shakes too also moves the field, which catches the eye. Sign in with a wrong password, or press Show me.
Try it
Change a setting, then try it again or press Show me.
Shake distance
How far the field swings left and right.
Number of swings
Four to six swings read as a head shake.
Speed
How long the whole shake lasts.
Copy the prompt
Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.
Add an error shake to [the form field that can be rejected, such as a password]. When the value is wrong or missing, move the field quickly left and right a few times, each swing smaller than the last, and end exactly where it started, like a head shaking no. Turn its border red and show a short message saying what went wrong, because movement and color alone do not explain the problem. Move only its horizontal position so the shake stays smooth, and restart the shake on every failed try. If the visitor has reduced motion turned on, skip the shake and keep the red border and the message. Match the settings listed below.
Your settings
Replace the words in brackets with your own element. Your settings are added at the end.
Free and open source. If this helped, a star on GitHub helps other people find it.
Star on GitHubWhat it is
The full explanation is in README.md.