PixelFadeIn

Fades children from opacity 0 to 1 with configurable duration, delay, easing, and trigger.

  • Mount, hover, click, or in-view triggers
  • Configurable duration, delay, easing, and fill-mode
  • Iteration count supports finite or infinite repeats
  • 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 { PixelFadeIn } from '@pxlkit/ui-kit';
PropTypeDefaultDescription
children (required)React.ReactNode—Content to fade in.
durationnumber400Animation duration in milliseconds. Default 400.
delaynumber0Animation delay in milliseconds. Default 0.
repeatnumber | 'infinite'1Iteration count: a number or 'infinite'. Default 1.
easingstring'ease'CSS animation-timing-function. Default 'ease'.
fillMode'none' | 'forwards' | 'backwards' | 'both''both'CSS animation-fill-mode. Default 'both'.
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

  • prefers-reduced-motion

Animation is suppressed when the user prefers reduced motion.

Usage

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

export function Default() {
  return (
    <PixelFadeIn>
      <div style={{ padding: 16, background: '#111', color: '#fff' }}>
        Fades in on mount
      </div>
    </PixelFadeIn>
  );
}

Examples

Default

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

export function Default() {
  return (
    <PixelFadeIn>
      <div style={{ padding: 16, background: '#111', color: '#fff' }}>
        Fades in on mount
      </div>
    </PixelFadeIn>
  );
}

Delayed

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

export function Delayed() {
  return (
    <PixelFadeIn duration={600} delay={200} easing="ease-out">
      <div style={{ padding: 16, background: '#0EA5E9', color: '#000' }}>
        Delayed fade-in
      </div>
    </PixelFadeIn>
  );
}

On Hover

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

export function OnHover() {
  return (
    <PixelFadeIn trigger="hover" duration={300}>
      <div style={{ padding: 16, background: '#222', color: '#0EA5E9' }}>
        Hover to fade in
      </div>
    </PixelFadeIn>
  );
}

Related