This component no longer exists. It was in PaceUI GSAP’s manifest when we first indexed it and is not there now — the registry served its inventory on 2026-08-06 and this item was not on it. The install command below will fail. It is kept here because a tutorial somewhere still tells people to run it.
Swap
paceui-gsap/swapRemovedComponent
A flexible swap component that animates content changes with smooth customizable transition effects.
Live preview
live · rendered by the registry
Rendered by PaceUI GSAP on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://gsap.paceui.com/r/swap.jsonSource
1import { ComponentProps, ReactNode, useMemo, useRef, useState } from "react";23import { useGSAP } from "@gsap/react";4import gsap from "gsap";56const effectPresets = {7 slideUp: [8 {9 y: "-100%",10 },11 {12 y: "100%",13 },14 {15 y: 0,16 },17 ],18 slideDown: [19 {20 y: "100%",21 },22 {23 y: "-100%",24 },25 {26 y: 0,27 },28 ],29 opacity: [30 {31 opacity: 0,32 },33 {34 opacity: 0,35 },36 {37 opacity: 1,38 },39 ],40 blur: [41 {42 filter: "blur(12px)",43 },44 {45 filter: "blur(12px)",46 },47 {48 filter: "blur(0px)",49 },50 ],51 grayscale: [52 {53 filter: "grayscale(100%)",54 },55 {56 filter: "grayscale(100%)",57 },58 {59 filter: "grayscale(0%)",60 },61 ],62} as const;6364export type SwapProps<T = object> = Omit<ComponentProps<"div">, "children"> & {65 state: T;66 children: (state: T) => ReactNode;67 effects?: (keyof typeof effectPresets)[];68 duration?: number;69};7071const mergeVars = (varsArray: Record<string, string | number>[]) => {72 const merged: Record<string, string | number> = {};7374 for (const vars of varsArray) {75 for (const [key, value] of Object.entries(vars)) {76 if (key === "filter" && merged.filter) {77 merged.filter += ` ${value}`; // combine filters78 } else {79 merged[key] = value; // last one wins for other props80 }81 }82 }8384 return merged;85};8687export const Swap = <T,>({ state, children, duration = 0.4, effects = [], ...props }: SwapProps<T>) => {88 const [currentState, setCurrentState] = useState(state);8990 const containerRef = useRef<HTMLDivElement>(null);91 const contentRef = useRef<HTMLDivElement>(null);9293 const [enterVars, exitVars, finalVars] = useMemo(94 () => Array.from({ length: 3 }, (_, i) => mergeVars(effects.map((e) => effectPresets[e][i]))),95 [effects],96 );9798 useGSAP(99 () => {100 if (currentState === state) return;101 const content = contentRef.current;102 if (!content) return;103104 gsap.to(content, {105 ...enterVars,106 duration,107 ease: "power2.in",108 onComplete: () => {109// … truncated
What it pulls in
npm packages
