Default
import { PixelShake } from '@pxlkit/ui-kit';
export function Default() {
return (
<PixelShake>
<span>Shake on mount</span>
</PixelShake>
);
}Quick horizontal shake animation, ideal for validation errors or attention cues.
onComplete (React), @complete (Vue), (complete) (Angular)import { PixelShake } from '@pxlkit/ui-kit';| Prop | Type | Default | Description |
|---|---|---|---|
children (required) | React.ReactNode | — | Content to shake. |
duration | number | 450 | Animation duration in milliseconds. Default 450. |
distance | number | 2 | Horizontal travel distance in pixels. Default 2. |
repeat | number | 'infinite' | 1 | Iteration count: a number or 'infinite'. Default 1. |
easing | string | 'linear' | CSS animation-timing-function. Default 'linear'. |
trigger | 'mount' | 'hover' | 'click' | 'focus' | 'inView' | boolean | 'mount' | When the animation should play. Default 'mount'. |
onComplete | () => void | — | Fires after the final iteration. |
className | string | — | Extra class names applied to the wrapping <div>. |
ref points to <div>.
WCAG target: 2.1 AA
respects prefers-reduced-motionAnimation is automatically disabled when the user has requested reduced motion.
import { PixelShake } from '@pxlkit/ui-kit';
export function Default() {
return (
<PixelShake>
<span>Shake on mount</span>
</PixelShake>
);
}import { PixelShake } from '@pxlkit/ui-kit';
export function Default() {
return (
<PixelShake>
<span>Shake on mount</span>
</PixelShake>
);
}import { PixelShake } from '@pxlkit/ui-kit';
export function OnHover() {
return (
<PixelShake trigger="hover" repeat="infinite" duration={300}>
<span>Hover to shake</span>
</PixelShake>
);
}import { PixelShake } from '@pxlkit/ui-kit';
export function StrongShake() {
return (
<PixelShake distance={6} duration={600} repeat={3}>
<span>Stronger shake</span>
</PixelShake>
);
}