Typed Split Wipe
A centered cursorless type build holds, then exits through opposing fixed-layout glyph wipes that leave the anchor visible longest.
Source
components/kuchi/typed-split-wipe.tsx
1"use client";23import type { CSSProperties } from "react";4import { Easing, interpolate, useCurrentFrame } from "remotion";56export interface TypedSplitWipeProps {7 prefix: string;8 anchor: string;9 suffix: string;10 typeFrames?: number;11 exitAt?: number;12 exitFrames?: number;13 wordStagger?: number;14 anchorShift?: number;15 fontSize?: number;16 color?: string;17 fontWeight?: number;18 speed?: number;19 className?: string;20}2122const clamp = {23 extrapolateLeft: "clamp" as const,24 extrapolateRight: "clamp" as const,25};26const wipeEasing = Easing.inOut(Easing.quad);2728export function getTypedSplitWipeText(29 text: string,30 frame: number,31 typeFrames: number,32) {33 const characters = Array.from(text);34 const typedLength = interpolate(35 frame,36 [0, Math.max(typeFrames, 0.001)],37 [0, characters.length],38 clamp,39 );40 const visibleLength = Math.min(41 characters.length,42 Math.max(frame >= 0 ? 1 : 0, Math.floor(typedLength) + 1),43 );44 return characters.slice(0, visibleLength).join("");45}4647export function TypedSplitWipe({48 prefix,49 anchor,50 suffix,51 typeFrames = 30,52 exitAt = 50,53 exitFrames = 20,54 wordStagger = 4,55 anchorShift = -72,56 fontSize = 42,57 color = "#e8e8e8",58 fontWeight = 400,59 speed = 1,60 className,61}: TypedSplitWipeProps) {62 const frame = useCurrentFrame() * speed;63 const fullText = [prefix, anchor, suffix].filter(Boolean).join(" ");64 const safeExitFrames = Math.max(exitFrames, 0.001);65 const typedText = getTypedSplitWipeText(fullText, frame, typeFrames);66 const suffixWords = suffix.trim().split(/\s+/).filter(Boolean);6768 const textStyle: CSSProperties = {69 color,70 fontFamily:71 "var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)",72 fontSize,73 fontWeight,74 letterSpacing: "-0.03em",75 lineHeight: 1,76 whiteSpace: "pre",77 };7879 const prefixExit = interpolate(80 frame,81 [exitAt, exitAt + safeExitFrames],82 [0, 1],83 { ...clamp, easing: wipeEasing },84 );85 const anchorExitStart = exitAt + Math.max(exitFrames - 6, 0);86 const anchorExit = interpolate(87 frame,88 [anchorExitStart, anchorExitStart + 6],89 [0, 1],90 { ...clamp, easing: wipeEasing },91 );9293 return (94 <div95 style={{96 position: "absolute",97 inset: 0,98 display: "flex",99 alignItems: "center",100 justifyContent: "center",101 overflow: "hidden",102 background: "transparent",103 }}104 >105 {frame < exitAt ? (106 <span className={className} style={textStyle}>107 {typedText}108 </span>109 ) : (110 <span111 className={className}112 style={{113 ...textStyle,114 display: "inline-flex",115 alignItems: "baseline",116 gap: "0.25em",117 }}118 >119 {prefix && (120 <span121 style={{122 display: "inline-block",123 clipPath: `inset(0 ${prefixExit * 100}% 0 0)`,124 }}125 >126 {prefix}127 </span>128 )}129130 {anchor && (131 <span132 style={{133 display: "inline-block",134 clipPath: `inset(0 ${anchorExit * 50}% 0 ${anchorExit * 50}%)`,135 transform: `translateX(${anchorShift * prefixExit}px)`,136 }}137 >138 {anchor}139 </span>140 )}141142 {suffixWords.map((word, index) => {143 const wordExitStart = exitAt + 2 + index * wordStagger;144 const wordExit = interpolate(145 frame,146 [wordExitStart, wordExitStart + safeExitFrames * 0.65],147 [0, 1],148 { ...clamp, easing: wipeEasing },149 );150151 return (152 <span153 key={`${word}-${index}`}154 style={{155 display: "inline-block",156 clipPath: `inset(0 0 0 ${wordExit * 100}%)`,157 }}158 >159 {word}160 </span>161 );162 })}163 </span>164 )}165 </div>166 );167}









