Command Palette
Search for a command to run

Text Rotate

Rotate through multiple text strings with per-character, per-word, or per-line motion and imperative controls.

motion-sv

Make it work!

Installation

pnpm dlx shadcn-svelte@latest add http://sveltekit-prerender/f/text-rotate.json
Visit Original Docs

For more deeper understaing visit fancy components documentation.

Props

PropTypeDefaultDescription
textsstring[]requiredArray of strings rotated through by the component.
askeyof SvelteHTMLElements"p"HTML element used for the animated text wrapper.
rotationIntervalnumber2000Delay in milliseconds between automatic text changes.
initialMotionProps["initial"] | MotionProps["initial"][]{ y: "100%", opacity: 0 }Initial motion state for each rendered segment. Arrays rotate through multiple states by index.
animateMotionProps["animate"] | MotionProps["animate"][]{ y: 0, opacity: 1 }Visible motion state for each rendered segment. Arrays rotate through multiple states by index.
exitMotionProps["exit"] | MotionProps["exit"][]{ y: "-120%", opacity: 0 }Exit motion state used when the current text leaves. Arrays rotate through multiple states by index.
autobooleantrueWhether the component should rotate automatically on an interval.
loopbooleantrueWhether rotation wraps back to the first string after the last.
splitBy"characters" | "words" | "lines" | string"characters"Controls how each text string is segmented before animation.
staggerDurationnumber0Delay added between animated segments.
staggerFrom"first" | "last" | "center" | "random" | number"first"Starting point used when calculating stagger delays.
transitionTransition{ type: "spring", damping: 25, stiffness: 300 }Motion transition shared by the layout wrapper and per-segment animations.
animatePresenceMode"sync" | "wait" | "popLayout""wait"AnimatePresence mode used when swapping from one text string to the next.
animatePresenceInitialbooleanfalseWhether the first render should run the enter animation.
onNext(index: number) => voidundefinedCallback invoked after the component rotates to a new text index.
mainClassNamestringundefinedClasses merged onto the root animated wrapper.
splitLevelClassNamestringundefinedClasses applied to each word or segment wrapper.
elementLevelClassNamestringundefinedClasses applied around each animated character or segment.
classstringundefinedAdditional classes merged onto the root layout wrapper.