Julien Thibeaut

Text Loop

Text 298

About

Text animation that transitions between multiple items, creating an engaging looping effect

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Text Loop to your project and fits it to your theme.

Code

How Text Loop is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import * as React from "react";
import { TextLoop } from "@/components/ui/text-loop";
import { Variants } from "framer-motion";

export function BasicDemo() {
  return (
    <div className="flex justify-center">
      <div className="w-[400px]">
        <TextLoop>
          {[
            "How can I assist you today?",
            "Generate a logo",
            "Create a component",
            "Draw a diagram",
          ].map((text) => (
            <span key={text} className="block text-left">
              {text}
            </span>
          ))}
        </TextLoop>
      </div>
    </div>
  );
}

export function CustomIntervalDemo() {
  return (
    <div className="flex justify-center">
      <div className="flex w-[400px]">
        <span className="mr-2">Beautiful templates for</span>
        <TextLoop interval={1}>
          {["Designers", "Design Engineers", "Developers"].map((text) => (
            <span key={text}>{text}</span>
          ))}
        </TextLoop>
      </div>
    </div>
  );
}

export function CustomAnimationDemo() {
  const [currentIndex, setCurrentIndex] = React.useState(0);

  const motionVariants: Variants = {
    initial: { y: 20, opacity: 0 },
    animate: { y: 0, opacity: 1 },
    exit: { y: currentIndex % 2 === 0 ? -20 : 20, opacity: 0 },
  };

  return (
    <div className="flex justify-center">
      <div className="w-[400px]">
        <TextLoop
          variants={motionVariants}
          onIndexChange={setCurrentIndex}
          interval={2}
          transition={{ duration: 0.3 }}
        >
          {[
            "La Trinité, Martinique",
            "A Little Lost・Arthur Russell"
          ].map((text) => (
            <span key={text} className="block text-left">
              {text}
            </span>
          ))}
        </TextLoop>
      </div>
    </div>
  );
}

export const demos = [
  {
    name: "Basic",
    description: "Basic text loop with default settings",
    component: BasicDemo,
  },
  {
    name: "Custom Interval",
    description: "Text loop with faster transition speed",
    component: CustomIntervalDemo,
  },
  {
    name: "Custom Animation",
    description: "Text loop with vertical slide animation",
    component: CustomAnimationDemo,
  },
];

Dependencies

More by Julien Thibeaut

View all
  • Dock

    Dock

    3.1K
  • Text Effect

    Text Effect

    1.6K
  • Infinite Slider

    Infinite Slider

    1.5K
  • Text Shimmer

    Text Shimmer

    1.3K
  • Text Scramble

    Text Scramble

    1.1K
  • Progressive blur

    Progressive blur

    683
  • Glow Effect

    Glow Effect

    610
  • Tailwind CSS Background Snippet

    Tailwind CSS Background Snippet

    536

More in Text

View all
  • Vertical Cut Reveal Characters

    Vertical Cut Reveal Characters

    103
  • Motion Blur Text

    Motion Blur Text

    36
  • NeonRGBTextEffect

    NeonRGBTextEffect

    144
  • Text Reveal

    Text Reveal

    27
  • Random Letter Swap

    Random Letter Swap

    46
  • Rainbow Text Effect

    Rainbow Text Effect

    47
  • Text Color

    Text Color

    545
  • Blur Reveal

    Blur Reveal

    300