AI Loading Text
AI Loading Text is a React and Tailwind CSS text component from Kokonut UI, licensed MIT. Copy it and paste it into your project.
Kokonut UI
MIT
text
What it is
AI Loading Text is a React and Tailwind CSS text component from Kokonut UI, licensed MIT. Copy it and paste it into your project.
How to use it
Open it in the catalogue, press copy, and paste it into your project. The prompt you copy carries the code and the rules that tell your agent to reproduce it without changing anything.
Five free copies a month. No card.
Needs
npm i motion
Licence
This component comes from Kokonut UI and is redistributed under the MIT licence, which permits commercial use. The copyright notice travels with the code.
AI Loading Text
"use client";
/**
* @author: @kokonutui
* @description: AI Text Loading
* @version: 1.0.0
* @date: 2025-06-26
* @license: MIT
* @website: https://kokonutui.com
* @github: https://github.com/kokonut-labs/kokonutui
*/
import { AnimatePresence, motion } from "motion/react";
import { useEffect, useState } from "react";
import { cn } from "@/lib/utils";
interface AITextLoadingProps {
texts?: string[];
className?: string;
interval?: number;
}
export default function AITextLoading({
texts = [
"Thinking...",
"Processing...",
"Analyzing...",
"Computing...",
"Almost...",
],
className,
interval = 1500,
}: AITextLoadingProps) {
const [currentTextIndex, setCurrentTextIndex] = useState(0);
useEffect(() => {
const timer = setInterval(() => {
setCurrentTextIndex((prevIndex) => (prevIndex + 1) % texts.length);
}, interval);
return () => clearInterval(timer);
}, [interval, texts.length]);
return (
<div className="flex items-center justify-center p-8">
<motion.div
animate={{ opacity: 1 }}
className="relative w-full px-4 py-2"
initial={{ opacity: 0 }}
transition={{ duration: 0.4 }}
>
<AnimatePresence mode="wait">
<motion.div
animate={{
opacity: 1,
y: 0,
backgroundPosition: ["200% center", "-200% center"],
}}
className={cn(
"flex min-w-max justify-center whitespace-nowrap bg-[length:200%_100%] bg-gradient-to-r from-neutral-950 via-neutral-400 to-neutral-950 bg-clip-text font-bold text-3xl text-transparent dark:from-white dark:via-neutral-600 dark:to-white",
className
)}
exit={{ opacity: 0, y: -20 }}
initial={{ opacity: 0, y: 20 }}
key={currentTextIndex}
transition={{
opacity: { duration: 0.3 },
y: { duration: 0.3 },
backgroundPosition: {
duration: 2.5,
ease: "linear",
repeat: Number.POSITIVE_INFINITY,
},
}}
>
{texts[currentTextIndex]}
</motion.div>
</AnimatePresence>
</motion.div>
</div>
);
}