Back to EffectsYou are on Slide.

Slide

An entrance that arrives from one side.

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

Libraries

PrequelUI

Motion

Spring + short tween

Reduced motion

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

Installation

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

Add the component

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/slide.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
slide.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 SlideProps = HTMLMotionProps<"div"> & {
  children?: React.ReactNode;
  delay?: number;
  direction?: SlideDirection;
  offset?: number;
  inView?: boolean;
  inViewOnce?: boolean;
  inViewMargin?: string;
  transition?: Transition;
  asChild?: boolean;
};

export function Slide({
  children,
  delay = 0,
  direction = "up",
  offset = 100,
  inView = false,
  inViewOnce = true,
  inViewMargin = "0px",
  transition,
  asChild = false,
  ...props
}: SlideProps) {
  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 axis = direction === "up" || direction === "down" ? "y" : "x";
  const hidden: Variant = reduce
    ? { opacity: 0 }
    : {
        [axis]:
          direction === "right" || direction === "down" ? -offset : offset,
      };
  const shown: Variant = reduce ? { opacity: 1 } : { [axis]: 0 };

  return (
    <Component
      ref={ref}
      data-slot="slide"
      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 SlideListProps = Omit<SlideProps, "children"> & {
  children: React.ReactElement | React.ReactElement[];
  holdDelay?: number;
};

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

Install

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

slide.tsx
import { Slide } from "@/components/prequelui/effects/slide";

export default function Demo() {
  return (
    <Slide direction="left" offset={60} className="rounded-xl border px-5 py-4">
      Slide into place.
    </Slide>
  );
}
import { Slide } from "@/components/prequelui/slide";

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

Animation

Slide uses one axis and one offset. The direction chooses between x and y and the sign of the travel, while the entrance spring carries the element to zero. Under reduced motion the same component falls back to a plain fade.

  • Entrance spring: stiffness 200, damping 20.
  • Default direction is up with a 100 px offset.
  • The crossing direction reads naturally: right and down enter from the negative side.
  • The list variant staggers children by holdDelay.
spring 200 / 20offset 100 pxsingle axisfade 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.

Slide

PropTypeDefault
direction"up" | "down" | "left" | "right""up"
offsetnumber100
delaynumber0
inViewbooleanfalse
inViewOncebooleantrue
inViewMarginstring"0px"
transitionTransitioncomponent spring or tween
asChildbooleanfalse
classNamestring—

Slides

PropTypeDefault
holdDelaynumber0
childrenReactElement[]—

Next component

Spotlight Card

A soft light that follows the pointer across a card on a lagging spring.