Shake

Single-shot shake — decaying x/y oscillation that settles back to centre. Trigger via ref or by changing the trigger prop. Use it for form validation errors, "wrong password" feedback, "card declined" states. GSAP-backed.

Reactive trigger — submit empty to shake the field

Usage

import { Shake, ShakeHandle } from '@bwo-ui/react';

// Imperative
const ref = useRef<ShakeHandle>(null);

<Shake ref={ref}>
  <Card />
</Shake>

<Button onClick={() => ref.current?.shake()}>Try again</Button>

// Reactive — bump the trigger value to fire
<Shake trigger={errorAttempt} intensity={6} axis="x">
  <PinInput />
</Shake>

Props

PropTypeDefaultDescription
axis'x' | 'y''x'Shake axis.
durationnumber0.5Total shake duration in seconds.
cyclesnumber6Number of full oscillations.
intensitynumber8Max displacement in pixels.
easestring'power1.out'GSAP ease.
triggerunknownWhen this value changes, fires the shake.
onComplete() => voidFires when the shake settles.
asElementType'div'Tag to render.