Fade

A simple opacity entrance tied to view or scroll.

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

Libraries

PrequelUI

Motion

Spring + short tween

Reduced motion

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

Installation

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

Add the component

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/fade.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
fade.tsx
"use client";

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

export type FadeProps = HTMLMotionProps<"div"> & {
  children?: React.ReactNode;
  delay?: number;
  initialOpacity?: number;
  opacity?: number;
  inView?: boolean;
  inViewOnce?: boolean;
  inViewMargin?: string;
  transition?: Transition;
  asChild?: boolean;
};

export function Fade({
  children,
  delay = 0,
  initialOpacity = 0,
  opacity = 1,
  inView = false,
  inViewOnce = true,
  inViewMargin = "0px",
  transition,
  asChild = false,
  ...props
}: FadeProps) {
  const ref = React.useRef<HTMLDivElement>(null);
  const visible = useInViewEffect(ref, inView, inViewOnce, inViewMargin);
  const base = useTempoTransition(transition ?? entranceSpring);
  const Component = (asChild ? Slot : motion.div) as React.ElementType;

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

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

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

Install

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/fade.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.

fade.tsx
import { Fade } from "@/components/prequelui/effects/fade";

export default function Demo() {
  return (
    <Fade opacity={1} className="text-4xl font-medium">
      A quiet entrance.
    </Fade>
  );
}
import { Fade } from "@/components/prequelui/fade";

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

Animation

The simplest entrance in the catalogue: a single opacity value on the entrance spring. Because it only touches opacity, it can be composed under a blur, a slide or a zoom without competing for the same property.

  • Spring: stiffness 200, damping 20.
  • Initial and final opacity are both configurable.
  • The list variant staggers the children by holdDelay.
  • Reduced motion keeps the fade; opacity is not a travel effect.
spring 200 / 20opacity 0 → 1staggered listreduced motion keeps fade
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.

Fade

PropTypeDefault
initialOpacitynumber0
opacitynumber1
delaynumber0
inViewbooleanfalse
inViewOncebooleantrue
inViewMarginstring"0px"
transitionTransitioncomponent spring or tween
asChildbooleanfalse
classNamestring—

Fades

PropTypeDefault
holdDelaynumber0
childrenReactElement[]—

Next component

Highlight

A shared background that slides to the active item.