Back to EffectsYou are on Effect.

Effect

Fade, blur, slide and zoom composed into one entrance.

Available inAvailable in React, Vue, Svelte, Solid, JavaScript· All five frameworks
PrequelUI

Libraries

PrequelUI

Motion

Spring + short tween

Reduced motion

Fade in place
effect.tsx
Play with the real component, then read the code it ships with.All components
01

Installation

Installing for React·components/prequelui/effects/effect.tsx

Add the component

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/effect.json
npmthe default on every machine

First component? Set up your project first

Frameworks

The live preview is React. Each tab below is the file that ships for that framework, with the same durations, springs and reduced-motion rule.

5 runtimes
effect.tsx
"use client";

import * as React from "react";
import {
  motion,
  type HTMLMotionProps,
  type Transition,
  type Variant,
} from "motion/react";
import { Slot, useReduceMotion, useTempoTransition } from "../motion";
import { entranceSpring, useInViewEffect, type SlideDirection } from "./shared";
export type { SlideDirection };

export type EffectSlide = { direction?: SlideDirection; offset?: number };
export type EffectFade = { initialOpacity?: number; opacity?: number };
export type EffectZoom = { initialScale?: number; scale?: number };
export type EffectBlur = { initialBlur?: number; blur?: number };

export type EffectProps = HTMLMotionProps<"div"> & {
  children?: React.ReactNode;
  delay?: number;
  blur?: EffectBlur | boolean;
  slide?: EffectSlide | boolean;
  fade?: EffectFade | boolean;
  zoom?: EffectZoom | boolean;
  inView?: boolean;
  inViewOnce?: boolean;
  inViewMargin?: string;
  transition?: Transition;
  asChild?: boolean;
};

export function Effect({
  children,
  delay = 0,
  blur = false,
  slide = false,
  fade = false,
  zoom = false,
  inView = false,
  inViewOnce = true,
  inViewMargin = "0px",
  transition,
  asChild = false,
  ...props
}: EffectProps) {
  const ref = React.useRef<HTMLDivElement>(null);
  const visible = useInViewEffect(ref, inView, inViewOnce, inViewMargin);
  const reduce = useReduceMotion();
  const base = useTempoTransition(transition ?? entranceSpring);
  const Component = (asChild ? Slot : motion.div) as React.ElementType;

  const hidden: Variant = {};
  const shown: Variant = {};

  if (slide && !reduce) {
    const config = typeof slide === "object" ? slide : {};
    const direction: SlideDirection = config.direction ?? "up";
    const offset = config.offset ?? 100;
    const axis = direction === "up" || direction === "down" ? "y" : "x";
    hidden[axis] = direction === "right" || direction === "down" ? -offset : offset;
    shown[axis] = 0;
  }

  if (fade) {
    const config = typeof fade === "object" ? fade : {};
    hidden.opacity = config.initialOpacity ?? 0;
    shown.opacity = config.opacity ?? 1;
  }

  if (zoom && !reduce) {
    const config = typeof zoom === "object" ? zoom : {};
    hidden.scale = config.initialScale ?? 0.5;
    shown.scale = config.scale ?? 1;
  }

  if (blur) {
    const config = typeof blur === "object" ? blur : {};
    hidden.filter = `blur(${reduce ? 0 : config.initialBlur ?? 10}px)`;
    shown.filter = `blur(${config.blur ?? 0}px)`;
  }

  if (reduce && (slide || zoom) && shown.opacity === undefined) {
    hidden.opacity = (fade && typeof fade === "object" ? fade.initialOpacity : 0) ?? 0;
    shown.opacity = (fade && typeof fade === "object" ? fade.opacity : 1) ?? 1;
  }

  return (
    <Component
      ref={ref}
      data-slot="effect"
      initial="hidden"
      animate={visible ? "visible" : "hidden"}
      exit="hidden"
      variants={{ hidden, visible: shown }}
      transition={{
        ...base,
        delay: (base.delay ?? 0) + delay / 1000,
      }}
      {...props}
    >
      {children}
    </Component>
  );
}

export type EffectsProps = Omit<EffectProps, "children"> & {
  children: React.ReactElement | React.ReactElement[];
  holdDelay?: number;
};

export function Effects({
  children,
  delay = 0,
  holdDelay = 0,
  ...props
}: EffectsProps) {
  return (
    <>
      {React.Children.toArray(children).map((child, index) => (
        <Effect key={index} delay={delay + index * holdDelay} {...props}>
          {child as React.ReactElement}
        </Effect>
      ))}
    </>
  );
}

Install

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/effect.json
npmthe default on every machine

Dependencies

motion lucide-react

The registry keeps the component source, its motion tokens and the reduced-motion branch together, so the install never pulls a different animation from the preview.

02

Usage

Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.

effect.tsx
import { Effect } from "@/components/prequelui/effects/effect";

export default function Demo() {
  return (
    <Effect
      fade
      blur
      zoom
      slide={{ direction: "up", offset: 24 }}
      className="rounded-xl border p-6"
    >
      Four properties, one gesture.
    </Effect>
  );
}
import { Effect } from "@/components/prequelui/effect";

export function Variant() {
  return (
    <Effect tempo={1.2}>
      …
    </Effect>
  );
}
03

Animation

Effect composes the four entrance primitives on a single element. Each option can be a boolean or a configuration object, and the hidden and visible variants are built once so the properties animate together on the same spring.

  • Slide defaults to 100 px upwards; each direction maps to x or y.
  • Fade defaults to opacity 0 → 1; zoom to scale 0.5 → 1; blur to 10 px → 0.
  • Reduced motion drops slide and zoom and keeps the fade.
  • The list variant staggers children by holdDelay.
spring 200 / 20fade · blur · slide · zoomdelay in msin-view once
04

API Reference

Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.

Effect

PropTypeDefault
fadeboolean | { initialOpacity, opacity }false
blurboolean | { initialBlur, blur }false
slideboolean | { direction, offset }false
zoomboolean | { initialScale, scale }false
delaynumber0
inViewbooleanfalse
inViewOncebooleantrue
inViewMarginstring"0px"
transitionTransitioncomponent spring or tween
classNamestring—

Effects

PropTypeDefault
holdDelaynumber0
childrenReactElement[]—

Next component

Fade

A simple opacity entrance tied to view or scroll.