A lightweight React component that creates a realistic typewriter animation effect with cursor blinking.
- π― Lightweight - Zero dependencies, tiny bundle (~11kb gzipped)
- β‘ Performant - Built with React hooks, optimized for speed
- π¨ Customizable - Colors, speed, font size, cursor blink
- βΏ Accessible - Semantic HTML, works with screen readers
- π¦ Tree-shakeable - Import only what you need
- π§ TypeScript - Full TypeScript support included
- π§ͺ Well tested - 100% test coverage
npm install react-text-typingor
yarn add react-text-typingimport TextTyping from "react-text-typing";
import "react-text-typing/css";
function App() {
return <TextTyping text="Hello, World!" />;
}<TextTyping text="Welcome to my website" /><TextTyping text="Fast typing" speed={50} /><TextTyping text="Custom colors" colorText="#ff6b6b" colorTyping="#4ecdc4" /><TextTyping text="No blink" showBlink={false} /><TextTyping text="Big text" fontSize="3em" /><TextTyping text="Callback example" onComplete={() => console.log("Done!")} /><TextTyping text="Heading" component="h1" className="my-heading" />| Prop | Type | Default | Description |
|---|---|---|---|
text |
string |
Required | Text to type out |
speed |
number |
500 |
Milliseconds between each character |
colorText |
string |
#fff |
Color of the typed text |
colorTyping |
string |
#0075D7 |
Color of the typing effect |
showBlink |
boolean |
true |
Show/hide cursor blink |
fontSize |
string |
5em |
Font size of the text |
timeTyping |
number |
10 |
Duration of typing animation (seconds) |
component |
string | Component |
"span" |
HTML element or custom component |
onComplete |
() => void |
- | Callback when typing finishes |
className |
string |
- | Additional CSS class |
The component includes default CSS. To customize, you can:
- Override CSS variables:
<TextTyping text="Custom" colorText="#ff0000" colorTyping="#00ff00" />- Add your own styles:
.text-typing {
font-family: "Fira Code", monospace;
}- Import only CSS and customize:
import "react-text-typing/css";# Install dependencies
npm install
# Run tests
npm test
# Run tests with coverage
npm run coverage
# Run Storybook
npm run dev
# Build library
npm run build:lib
# Lint
npm run lintContributions are welcome! Please read our contributing guidelines first.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
We use Storybook for component development and documentation. Run npm run dev to explore the component in an interactive environment.
Found a bug? Please open an issue with a detailed description.
MIT License - see the LICENSE file for details.
Made with β€οΈ by Renato Oda
