Zoom

An entrance that scales from half size with a spring.

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

Libraries

PrequelUI

Motion

Spring + short tween

Reduced motion

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

Installation

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

Add the component

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

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

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

export function Zoom({
  children,
  delay = 0,
  initialScale = 0.5,
  scale = 1,
  inView = false,
  inViewOnce = true,
  inViewMargin = "0px",
  transition,
  asChild = false,
  ...props
}: ZoomProps) {
  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;

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

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

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

Install

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

zoom.tsx
import { Zoom } from "@/components/prequelui/effects/zoom";

export default function Demo() {
  return (
    <Zoom initialScale={0.5} className="rounded-2xl bg-accent p-8">
      Zoom
    </Zoom>
  );
}
import { Zoom } from "@/components/prequelui/zoom";

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

Animation

The element arrives from half size on the entrance spring. Scale is a transform, so the entrance never reflows the surrounding layout; the origin stays centred unless the component is composed with a different transform origin.

  • Entrance spring: stiffness 200, damping 20.
  • Initial scale and final scale are configurable.
  • The list variant staggers the children by holdDelay.
  • Reduced motion replaces the scale with a fade.
spring 200 / 20scale 0.5 → 1staggered listfade fallback
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.

Zoom

PropTypeDefault
initialScalenumber0.5
scalenumber1
delaynumber0
inViewbooleanfalse
inViewOncebooleantrue
inViewMarginstring"0px"
transitionTransitioncomponent spring or tween
asChildbooleanfalse
classNamestring—

Zooms

PropTypeDefault
holdDelaynumber0
childrenReactElement[]—

Next component

Bubble

Slow gradient blobs that float and turn behind the content.