LayerwiseLayerwise
  • Features
  • Pricing
  • Templates
  • Docs
DownloadDownload
FeaturesPricingTemplatesDocsAI Website BuilderVibe CodingPersonal Software
DownloadDownload
  1. Glossary
  2. /
  3. Interaction feedback

Shake animation

Also called error shake or wiggle animation

A quick side-to-side jiggle that tells someone their input was rejected, such as a wrong password or an invalid code.

import { useId, useState, type FormEvent } from 'react';
import { useAnimate, useReducedMotion } from 'motion/react';

// Each swing is smaller than the last, like a head shaking "no".
const SHAKE_X = [0, -10, 10, -8, 8, -4, 4, 0];
const SHAKE = { duration: 0.45, ease: 'easeInOut' } as const;

type PasswordFormProps = {
  verify: (password: string) => Promise<boolean>;
};

export function PasswordForm({ verify }: PasswordFormProps) {
  const id = useId();
  const [scope, animate] = useAnimate<HTMLInputElement>();
  const [password, setPassword] = useState('');
  const [error, setError] = useState(false);
  const reduceMotion = useReducedMotion();

  async function onSubmit(event: FormEvent<HTMLFormElement>) {
    event.preventDefault();
    if (await verify(password)) return;
    setError(true);
    // With reduced motion, the red border and message carry the error alone.
    if (!reduceMotion) animate(scope.current, { x: SHAKE_X }, SHAKE);
  }

  return (
    <form onSubmit={onSubmit} className='flex w-72 flex-col gap-2'>
      <label htmlFor={id} className='text-sm font-medium'>
        Password
      </label>
      <input
        ref={scope}
        id={id}
        type='password'
        value={password}
        onChange={(event) => {
          setPassword(event.target.value);
          setError(false);
        }}
        aria-invalid={error}
        aria-describedby={error ? `${id}-error` : undefined}
        className='rounded-lg border bg-background px-3 py-2 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring aria-invalid:border-red-500 aria-invalid:ring-red-500/30'
      />
      {error && (
        <p id={`${id}-error`} role='alert' className='text-sm text-red-600'>
          Incorrect password. Try again.
        </p>
      )}
      <button
        type='submit'
        className='mt-2 rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground'
      >
        Sign in
      </button>
    </form>
  );
}
When sign-in fails, shake the password field horizontally with keyframes of 0, -10px, 10px, -8px, 8px, -4px, 4px, 0 over 450ms with an ease-in-out curve. At the same time turn its border red and show "Incorrect password. Try again." below it. Replay the shake on every failed attempt, clear the error when the user types, and skip the shake when prefers-reduced-motion is set.

Paste into Layerwise or any AI coding tool.

What is Shake animation?

A shake moves an element left and right a few times in under half a second, with each swing smaller than the last. It mimics a head shaking "no", so people sense the problem before they read the error. The macOS login screen shakes the password field this way.

Use it for a failed sign-in, a wrong one-time code, or a form submitted with missing fields. Always pair it with a visible error message and a color change: the shake grabs attention, and the text explains what to fix.

Keep it short, about 300 to 500ms, with swings of 6 to 12px; bigger swings feel harsh. Some people find sudden motion uncomfortable, so when prefers-reduced-motion is set, skip the shake and rely on the red border and message.

Related terms

All terms

Inline validation

Form checking that happens right next to each field as you fill it in, showing an error or a checkmark before you press Submit.

Keyframes

Snapshots that define how an element looks at set points in an animation. The browser fills in the motion between them.

Reduced motion

An operating system setting that asks apps to minimize movement, which websites detect with the prefers-reduced-motion media query.

Micro-interaction

A small moment of feedback around a single action, like a heart that bursts when tapped or a copy icon that turns into a checkmark.

Build it with Layerwise

Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.

DownloadDownloadRead the docs
LayerwiseLayerwise

Build full-stack web apps in minutes with AI.

Product

  • Features
  • Pricing
  • Download
  • Templates

Solutions

  • AI Website Builder
  • Vibe Coding
  • Personal Software

Resources

  • Documentation
  • Changelog
  • Blog
  • Vibe Coding Glossary
  • llms.txt
  • llms-full.txt

Company

  • About
  • Contact

Legal

  • Privacy
  • Analytics Privacy
  • Terms
  • Security
  • Abuse

© 2026 Layerwise. All rights reserved.

Entrances & exits

  • Fade in
  • Slide in
  • Scale in
  • Pop in
  • Blur in
  • Reveal animation
  • Enter and exit animations

Timing & sequencing

  • Duration
  • Delay
  • Keyframes
  • Tweening
  • Stagger
  • Orchestration
  • Fill mode
  • Stepped animation
  • Looping animation
  • Yoyo animation

Easing

  • Easing
  • Linear easing
  • Ease-in
  • Ease-out
  • Ease-in-out
  • Cubic-bezier
  • Asymmetric easing
  • Overshoot easing

Springs & physics

  • Spring animation
  • Stiffness
  • Damping
  • Mass
  • Bounce
  • Velocity
  • Momentum
  • Interruptible animation
  • Rubber-banding

Transforms

  • Translate
  • Scale
  • Rotate
  • Skew
  • 3D flip
  • Perspective
  • Transform origin
  • Origin-aware animation

State transitions

  • Crossfade
  • Morph
  • Shared element transition
  • Layout animation
  • Height auto animation
  • Direction-aware transition
  • Continuity transition
  • Page transition
  • View Transitions API

Scroll effects

  • Scroll reveal
  • Scroll-driven animation
  • Parallax scrolling
  • Scrollytelling
  • Scroll pinning
  • Horizontal scroll section
  • Scroll progress bar
  • Scroll snap
  • Smooth scrolling

Interaction feedback

  • Hover effect
  • Press feedback
  • Ripple effect
  • Shake animation
  • Hold to confirm
  • Drag gesture
  • Drag to reorder
  • Swipe to dismiss
  • Pull to refresh
  • Magnetic button
  • Custom cursor
  • 3D tilt card
  • Spotlight card

Text effects

  • Typewriter effect
  • Text scramble
  • Split text animation
  • Text morph
  • Rotating words
  • Gradient text
  • Shimmer text
  • Number ticker
  • Tabular numbers
  • Underline animation

Loops & ambient motion

  • Marquee
  • Pulse animation
  • Float animation
  • Orbit animation
  • Idle animation
  • Particle background
  • Border beam
  • Confetti
  • Animated gradient

Visual effects

  • Blur
  • Clip-path
  • Mask
  • Before/after slider
  • SVG line drawing
  • Lottie animation

Motion principles

  • Purposeful animation
  • Anticipation
  • Follow-through
  • Squash and stretch
  • Perceived performance
  • Frequency of use
  • Spatial consistency
  • Reduced motion

Animation performance

  • Frame rate (FPS)
  • Jank
  • GPU acceleration
  • will-change
  • Layout thrashing

Layout

  • Hero section
  • Above the fold
  • Sticky header
  • Sidebar
  • Bento grid
  • Card
  • Flexbox
  • CSS Grid
  • Padding vs margin
  • Responsive design
  • Container
  • Masonry layout
  • Split screen
  • Z-index
  • Overflow

Components

  • Button variants
  • Modal
  • Drawer
  • Popover
  • Tooltip
  • Dropdown menu
  • Context menu
  • Toast notification
  • Tabs
  • Segmented control
  • Accordion
  • Carousel
  • Command palette
  • Combobox
  • Toggle switch
  • Checkbox
  • Radio button
  • Date picker
  • Breadcrumb
  • Pagination
  • Infinite scroll
  • Badge
  • Avatar stack
  • Empty state
  • Skeleton screen
  • Spinner
  • Progress bar
  • Data table
  • Stepper
  • Floating label
  • Inline validation
  • Alert banner
  • Tag input

States & patterns

  • Interaction states
  • Focus ring
  • Loading state
  • Optimistic UI
  • Debounce
  • Lazy loading
  • Dark mode
  • Micro-interaction
  • Affordance
  • Undo
  • Drag and drop
  • Keyboard shortcut

Visual styles

  • Glassmorphism
  • Liquid glass
  • Neumorphism
  • Claymorphism
  • Neo-brutalism
  • Skeuomorphism
  • Flat design
  • Mesh gradient
  • Aurora background
  • Grain texture
  • Glow effect
  • Drop shadow
  • Border radius
  • Grid background
  • Typographic hierarchy
  • Accent color
  • Color contrast

Vibe coding & AI

  • Vibe coding
  • Prompt
  • Context window
  • Token
  • AI agent
  • Tool call
  • Hallucination
  • Diff
  • Live preview
  • Checkpoint
  • Git commit
  • Deploy
  • Frontend and backend
  • API
  • Database
  • Rules file
  • MCP
  • Plan mode
  • Visual edit
Password
Sign in