react-typing-animator
Version:
A React component that animates a given text array into a looping typing animation of each word.
53 lines (52 loc) • 2.32 kB
TypeScript
import React, { CSSProperties } from "react";
import "./index.css";
interface Props {
textArray: string[];
cursorColor?: string;
textColor?: string;
fontSize?: string;
typingSpeed?: number;
delaySpeed?: number;
backspace?: boolean;
height?: string;
loop?: boolean;
dynamicDelay?: boolean;
displayCursor?: boolean;
style?: CSSProperties;
}
/**
* React Typing Animator is a React component that animates an array of texts in a typing sequence with a blinking cursor.
*
* @param {Props} props - Props for React Typing Animator component.
* @param {string[]} props.textArray - Required Array of strings to be animated in the typing sequence.
* @param {string} [props.cursorColor="black"] - Color of the blinking cursor.
* @param {string} [props.textColor="black"] - Color of the animated text.
* @param {string} [props.fontSize="1rem"] - Font size of the animated text.
* @param {number} [props.typingSpeed=200] - Speed of typing in milliseconds.
* @param {number} [props.delaySpeed=1500] - Delay between typing each word in milliseconds.
* @param {boolean} [props.backspace=false] - Whether to backspace the text after typing it.
* @param {string} [props.height="40px"] - Height of the container for the animated text.
* @param {boolean} [props.loop=true] - Whether to loop the animation after completing the text array.
* @param {boolean} [props.dynamicDelay=false] - Whether to add a dynamic delay based on the length of the text.
* @param {boolean} [props.displayCursor=true] - Whether to display the blinking cursor.
* @param {CSSProperties} [props.style={}] - Additional CSS styles for the container.
* @returns {JSX.Element} The animated text component with a cursor.
*
* @example
* <TypingAnimator
* textArray={["Hello", "World"]}
* cursorColor="#FF0000"
* textColor="#000000"
* fontSize="2rem"
* typingSpeed={100}
* delaySpeed={2000}
* backspace={true}
* height="50px"
* loop={true}
* dynamicDelay={true}
* displayCursor={true}
* style={{ margin: "20px", textAlign: "center" }}
* />
*/
declare const TypingAnimator: ({ textArray, cursorColor, textColor, fontSize, typingSpeed, delaySpeed, backspace, height, loop, dynamicDelay, displayCursor, style, }: Props) => React.JSX.Element;
export default TypingAnimator;