PixelBounce

Vertical bounce animation with damped follow-through for any inline content.

  • Configurable bounce height, duration, easing, and repeat count
  • Trigger modes: mount, hover, focus, viewport
  • Signals the end of its last iteration: onComplete (React), @complete (Vue), (complete) (Angular)
  • Respects prefers-reduced-motion automatically
Status
stable
Category
animations
Since
v1.6.0

API

import { PixelBounce } from '@pxlkit/ui-kit';
PropTypeDefaultDescription
children (required)React.ReactNode—Content to bounce.
durationnumber800Animation duration in milliseconds. Default 800.
repeatnumber | 'infinite''infinite'Iteration count: a number or 'infinite'. Default 'infinite'.
heightnumber8Peak bounce height in pixels. Default 8.
easingstring'ease'CSS animation-timing-function. Default 'ease'.
trigger'mount' | 'hover' | 'click' | 'focus' | 'inView' | boolean'mount'When the animation should play. Default 'mount'.
onComplete() => void—Fires after the final iteration.
classNamestring—Extra class names applied to the wrapping <div>.

ref points to <div>.

Accessibility

WCAG target: 2.1 AA

  • respects prefers-reduced-motion

Animation is suppressed when the user has requested reduced motion.

Usage

import { PixelBounce } from '@pxlkit/ui-kit';

export function Default() {
  return (
    <PixelBounce>
      <span>Bounce</span>
    </PixelBounce>
  );
}

Examples

Default

import { PixelBounce } from '@pxlkit/ui-kit';

export function Default() {
  return (
    <PixelBounce>
      <span>Bounce</span>
    </PixelBounce>
  );
}

Taller Bounce

import { PixelBounce } from '@pxlkit/ui-kit';

export function TallerBounce() {
  return (
    <PixelBounce height={16} duration={1000}>
      <span>Higher Jump</span>
    </PixelBounce>
  );
}

Hover Trigger

import { PixelBounce } from '@pxlkit/ui-kit';

export function HoverTrigger() {
  return (
    <PixelBounce trigger="hover" repeat={1}>
      <span>Hover me</span>
    </PixelBounce>
  );
}

Related