实时终端窗口预览
在精致的深色极客终端窗口中,直观查看多行文字流畅打出与逐字消除的视觉效果。
打字机效果生成器
实时自定义并预览逐字打字与回退删除动画效果,一键导出可直接用于生产环境的 React、原生 JS 及纯 CSS 代码。
import React, { useState, useEffect } from "react";
export function Typewriter() {
const words = [
"Hello, World! 👋",
"Build beautiful web applications.",
"100% Client-Side Typewriter Effect.",
"Fast, smooth, and fully customizable."
];
const [currentText, setCurrentText] = useState("");
const [wordIdx, setWordIdx] = useState(0);
const [isDeleting, setIsDeleting] = useState(false);
useEffect(() => {
const currentWord = words[wordIdx % words.length];
let timer;
if (!isDeleting) {
if (currentText.length < currentWord.length) {
timer = setTimeout(() => {
setCurrentText(currentWord.slice(0, currentText.length + 1));
}, 80);
} else {
timer = setTimeout(() => setIsDeleting(true), 1500);
}
} else {
if (currentText.length > 0) {
timer = setTimeout(() => {
setCurrentText(currentWord.slice(0, currentText.length - 1));
}, 40);
} else {
setIsDeleting(false);
setWordIdx((prev) => (prev + 1) % words.length);
}
}
return () => clearTimeout(timer);
}, [currentText, isDeleting, wordIdx]);
return (
<div className="font-mono text-2xl font-bold text-slate-100 flex items-center">
<span>{currentText}</span>
<span className="animate-pulse ml-0.5 text-blue-500">|</span>
</div>
);
}轻松打造为网站首屏、作品集与落地页增色添彩的交互式打字机动画。
在精致的深色极客终端窗口中,直观查看多行文字流畅打出与逐字消除的视觉效果。
灵活调整打字频率、退格速率、语句留白时间,并自选竖线(|)、下划线(_)或色块(█)光标。
一键获取兼容 React 组件、纯原生 HTML/JS 脚本及纯 CSS 动画的关键帧代码。
在工作间隙让大脑放松一下的免费网页经典游戏合集。