Text Rotate
fancy/text-rotateFreeComponent
A ui component.
Install it
npx shadcn@latest add https://www.fancycomponents.dev/r/text-rotate.jsonSource
1"use client"23import {4 ElementType,5 forwardRef,6 useCallback,7 useEffect,8 useImperativeHandle,9 useMemo,10 useState,11} from "react"12import {13 AnimatePresence,14 AnimatePresenceProps,15 motion,16 MotionProps,17 Transition,18} from "motion/react"1920import { cn } from "@/lib/utils"2122// handy function to split text into characters with support for unicode and emojis23const splitIntoCharacters = (text: string): string[] => {24 if (typeof Intl !== "undefined" && "Segmenter" in Intl) {25 const segmenter = new Intl.Segmenter("en", { granularity: "grapheme" })26 return Array.from(segmenter.segment(text), ({ segment }) => segment)27 }28 // Fallback for browsers that don't support Intl.Segmenter29 return Array.from(text)30}3132interface TextRotateProps {33 /**34 * Array of text strings to rotate through.35 * Required prop with no default value.36 */37 texts: string[]3839 /**40 * render as HTML Tag41 */42 as?: ElementType4344 /**45 * Time in milliseconds between text rotations.46 * @default 200047 */48 rotationInterval?: number4950 /**51 * Initial animation state or array of states.52 * @default { y: "100%", opacity: 0 }53 */54 initial?: MotionProps["initial"] | MotionProps["initial"][]5556 /**57 * Animation state to animate to or array of states.58 * @default { y: 0, opacity: 1 }59 */60 animate?: MotionProps["animate"] | MotionProps["animate"][]6162 /**63 * Animation state when exiting or array of states.64 * @default { y: "-120%", opacity: 0 }65 */66 exit?: MotionProps["exit"] | MotionProps["exit"][]6768 /**69 * AnimatePresence mode70 * @default "wait"71 */72 animatePresenceMode?: AnimatePresenceProps["mode"]7374 /**75 * Whether to run initial animation on first render.76 * @default false77 */78 animatePresenceInitial?: boolean7980 /**81 * Duration of stagger delay between elements in seconds.82 * @default 083 */84 staggerDuration?: number8586 /**87 * Direction to stagger animations from.88 * @default "first"89 */90 staggerFrom?: "first" | "last" | "center" | number | "random"9192 /**93 * Animation transition configuration.94 * @default { type: "spring", damping: 25, stiffness: 300 }95 */96 transition?: Transition9798 /**99 * Whether to loop through texts continuously.100 * @default true101 */102 loop?: boolean103104 /**105 * Whether to auto-rotate texts.106 * @default true107 */108 auto?: boolean109110 /**111 * How to split the text for animation.112 * @default "characters"113 */114 splitBy?: "words" | "characters" | "lines" | string115116 /**117// … truncated
What it pulls in
npm packages
Files it writes
More from fancy
All 158 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Gradient With Svganimated-gradient-with-svg | fancy | Components | Free | no deps | |
| Basic Number Tickerbasic-number-ticker | fancy | Components | Free | 1 dep | |
| Box Carouselbox-carousel | fancy | Components | Free | 1 dep | |
| Breathing Textbreathing-text | fancy | Components | Free | 1 dep | |
| Circling Elementscircling-elements | fancy | Components | Free | 1 dep | |
| Css Boxcss-box | fancy | Components | Free | 1 dep | |
| Cursor Attractor And Gravitycursor-attractor-and-gravity | fancy | Components | Free | 5 deps | |
| Drag Elementsdrag-elements | fancy | Components | Free | 1 dep |
