Typewriter Effect, animated React component
A typewriter with a physical caret: each new character drops in and settles on a spring, the caret stretches on every keystroke and squashes on every delete, and it only blinks while it waits. Type one phrase, rotate through a list, or loop forever.
- Free
- Motion Effects
- Spring
Types with a key click for every character, in sync with the text. The click stays off until you switch it on.
Like Typewriter Effect? 256 more are in Pro.
Pro unlocks all 256 Pro components, every template and block, and everything we release next. Typewriter Effect stays free.
Play with it
Move the controls and watch it change. Copy code gives you a snippet with only the props you changed.
Ship faster. Build better. Delight users.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| text | string | string[] | — | One phrase, or a list typed one after another. |
| typingSpeed | number | 65 | Milliseconds per typed character, with a little human jitter. |
| deletingSpeed | number | 42 | Milliseconds per deleted character. 0 swaps straight to the next phrase. |
| delay | number | 0 | Milliseconds before the first character. |
| pauseDuration | number | 1200 | Milliseconds a finished phrase is held. |
| loop | boolean | false | Starts again from the first phrase after the last one. |
| showCursor | boolean | true | Shows the caret. |
| cursorClassName | string | — | Classes for the caret; it uses the text colour by default. |
| as | "h1" | "h2" | "p" | "span" | "div" | "span" | Root element. |
| className | string | — | Classes for the root element. |
| onComplete | () => void | — | Called each time the last phrase finishes. |
| autoplay | boolean | false | Loops until someone clicks or taps the text, then stops after the current phrase. |
Add it to your project
- 1
Set up your project once
You need a Next.js project with Tailwind CSS and the
@/import alias. In its root folder, run this once. It createscomponents.jsonand thecn()helper insrc/lib/utils.ts:npx shadcn@latest init -d
Starting from nothing? The Quick Start walks through the whole thing.
- 2
Connect the registry
Run this once per project. It writes the Nexus UI entry into
components.jsonfor you:npx shadcn@latest registry add "@nexus-labs=https://www.nexus-ui.com/api/registry/{name}"Type it exactly as shown.
{name}is filled in by the CLI with the component you ask for, so you never replace it.
- 3
Add the component
Run this from your project root. It adds the component, the helpers it imports and its npm packages.
npx shadcn@latest add @nexus-labs/typewriter-effect
- 4
Check what was added
With a project made as in the Quick Start (a
src/folder), these files land in it:components/typewriter-effect/index.tstypewriter-effect.tsx - 5
Copying by hand? Skip the registry
Instead of steps 2 and 3 you can copy the files yourself, with no registry and no API key. Step 1 still applies, so that
cn()exists. Install the packages:npm install framer-motion
Then show the source and create each file at the path it gives:
- 6
Use it in a page
Installing only adds the files. Import the component in a page and render it. The Usage tab on the preview shows a fuller example with props:
// src/app/page.tsx import { TypewriterEffect } from "@/components/typewriter-effect"; export default function Page() { return ( <main> <TypewriterEffect /> </main> ); }
Like Typewriter Effect? 256 more are in Pro.
Pro unlocks all 256 Pro components, every template and block, and everything we release next. Typewriter Effect stays free.
About Typewriter Effect
The Typewriter Effect is a text cycling component that types, pauses, and deletes through an array of strings character by character. Typing speed, pause duration, and deletion speed are independently configurable. A blinking cursor animates between cycles with a CSS keyframe. The component includes an aria-live region so screen readers announce the changing content. The standard hero headline pattern for products serving multiple use cases — each string can target a different audience segment.
Good for
- Hero section value proposition cycles
- Multi-audience product taglines
- Feature benefit rotation
- Animated product description displays
Typewriter Effect questions
How do I install the typewriter effect?
Run `npx shadcn@latest add @nexus-labs/typewriter-effect`. It adds the TypewriterEffect component and installs framer-motion for the cursor blink.
How do I rotate through several phrases?
Pass an array to `text`. Each phrase is typed, held for `pauseDuration` ms, deleted at `deletingSpeed`, and the next one starts; set `loop` to repeat forever. Setting `deletingSpeed` to 0 switches phrases without the delete animation.
Is the text readable by screen readers and search engines?
Yes. The full text is rendered in a visually hidden span while the animated letters are hidden from assistive tech, and `as` lets you render it as an `h1`, `h2`, `p`, `span` or `div`.
What happens with reduced motion?
With prefers-reduced-motion on, it skips typing and shows the final phrase immediately. `onComplete` still fires.