Julien Thibeaut

Text Loop

Text 306

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.2K
  • Text Effect

    Text Effect

    1.7K
  • Infinite Slider

    Infinite Slider

    1.5K
  • Text Shimmer

    Text Shimmer

    1.3K
  • Text Scramble

    Text Scramble

    1.1K
  • Progressive blur

    Progressive blur

    691
  • Glow Effect

    Glow Effect

    618
  • Tailwind CSS Background Snippet

    Tailwind CSS Background Snippet

    568

More in Text

View all
  • Rainbow Text Effect

    Rainbow Text Effect

    51
  • NeonRGBTextEffect

    NeonRGBTextEffect

    149
  • Vertical Cut Reveal Characters

    Vertical Cut Reveal Characters

    120
  • Apple Hello Effect

    Apple Hello Effect

    632
  • Text Highlight

    Text Highlight

    80
  • Text Reveal

    Text Reveal

    32
  • Text Loop

    Text Loop

    328
  • Blur Reveal

    Blur Reveal

    317