Xem trước giao diện dòng lệnh trực tiếp
Theo dõi văn bản của bạn xuất hiện và biến mất mượt mà trong khung giao diện tối sang trọng.
Hiệu ứng máy đánh chữ
Tùy chỉnh và xem trước hoạt ảnh gõ và xóa văn bản mượt mà theo thời gian thực, xuất mã nguồn sạch cho React, JavaScript và 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>
);
}Tạo các tiêu đề hoạt ảnh hấp dẫn cho trang chủ và trang đích của bạn.
Theo dõi văn bản của bạn xuất hiện và biến mất mượt mà trong khung giao diện tối sang trọng.
Tùy chỉnh tốc độ gõ phím, xóa lùi, thời gian chờ và kiểu dáng con trỏ nhấp nháy.
Nhận đoạn mã hoàn chỉnh có thể dán ngay vào các dự án web của bạn.
Cần 2 phút thư giãn tinh thần? Bước vào trò chơi giải đố cổ điển ngay trong trình duyệt của bạn.