npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-mk

v2.0.0

Published

A lightweight, zero-dependency React typewriter component with realistic typing animations.

Readme

A lightweight, zero-dependency React typewriter component with realistic typing animations.

Features

  • Zero dependencies — no CSS-in-JS library required, works right out of the box
  • Modern React 19+ — built with hooks and the react-jsx transform
  • useTypewriter hook — extract the core engine for fully custom UIs
  • Declarative actions — composable type(), pause(), deleteAll(), deleteChars() builders
  • sentences prop — cycle through an array of strings with one prop
  • Looping — infinite or N iterations via the loop prop
  • Realistic typo simulation — set mistakeChance for QWERTY-aware "mistake → correct" animations
  • Live speed changes — dynamically update typeSpeed / deleteSpeed mid-animation
  • CallbacksonType, onDelete, onFinish, onLoop
  • Accessiblearia-hidden cursor, automatic prefers-reduced-motion support
  • Tree-shakeable ESM — modern exports field with sideEffects: false
  • Fully typed — comprehensive TypeScript definitions with JSDoc

Install

npm i react-mk

Quick Start

import Typewriter, { Cursor } from 'react-mk';

function App() {
  return (
    <p>
      <Typewriter>Hello World</Typewriter>
      <Cursor />
    </p>
  );
}

Usage

Simple Text

<Typewriter>Any string or number works here</Typewriter>

Action Sequences

Use the render-prop pattern to compose typing, pausing, and deleting:

<Typewriter>
  {({ type, pause, deleteAll }) => [
    type('Hello World'),
    pause(2000),
    deleteAll(),
    type('React MK v2'),
  ]}
</Typewriter>

Sentence Cycling

The sentences prop makes it trivial to cycle through an array of strings:

<Typewriter
  sentences={['First sentence', 'Second sentence', 'Third sentence']}
  sentenceDelay={2000}
  loop
/>

useTypewriter Hook

For full control, use the hook directly:

import { useTypewriter, type, pause, deleteAll, Cursor } from 'react-mk';

function CustomTypewriter() {
  const { text, phase } = useTypewriter(
    [type('Hello'), pause(1000), deleteAll(), type('World')],
    { loop: true, typeSpeed: [40, 80] },
  );

  return (
    <h1>
      {text}
      {phase !== 'complete' && <Cursor />}
    </h1>
  );
}

Realistic Typos

Add mistakeChance for humanized typing that makes QWERTY-adjacent mistakes and self-corrects:

<Typewriter mistakeChance={0.06} typeSpeed={[60, 120]}>
  This text will have occasional realistic typos that get corrected
</Typewriter>

Custom Cursors

<Cursor />                          {/* Default: blinking | */}
<Cursor blink={false}>_</Cursor>    {/* Static underscore */}
<Cursor blinkSpeed={300}>█</Cursor> {/* Fast-blinking block */}

API Reference

<Typewriter> Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | children | string \| number \| ((builders) => Action[]) | — | Content to type or render-prop returning actions | | sentences | string[] | — | Array of sentences to cycle through (takes priority over children) | | sentenceDelay | number | 2000 | Ms each sentence is shown before deletion | | typeSpeed | [min, max] | [50, 90] | Delay range between keystrokes (ms) | | deleteSpeed | [min, max] | [30, 60] | Delay range between deletions (ms) | | loop | boolean \| number | false | true for infinite, or a number for N iterations | | loopDelay | number | 1000 | Ms before restarting the loop | | startDelay | number | 0 | Ms before the animation begins | | mistakeChance | number | 0 | Probability (0–1) of a typo per character | | onType | (char, text) => void | — | Called after each character is typed | | onDelete | (char, text) => void | — | Called after each character is deleted | | onFinish | () => void | — | Called when all actions complete | | onLoop | (count) => void | — | Called when the animation loops |

useTypewriter(actions, options)

Returns { text, phase, loopCount }.

  • text — The currently displayed string
  • phase — One of 'idle' | 'typing' | 'deleting' | 'pausing' | 'complete'
  • loopCount — Current loop iteration (0-indexed)

<Cursor> Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | blink | boolean | true | Enable/disable blink animation | | blinkSpeed | number | 530 | Blink cycle duration (ms) | | children | ReactNode | \| | Cursor character(s) | | ...rest | HTMLSpanElement props | — | Spread to the root <span> |

Action Builders

| Builder | Description | |---------|-------------| | type(text) | Type a string character by character | | pause(ms) | Pause for a duration in milliseconds | | deleteAll() | Delete all currently displayed text | | deleteChars(n) | Delete n characters from the end |

Migration from v1

  • KeyboardTypewriter (default export renamed)
  • @emotion/css removed — Cursor now uses pure CSS, no imports needed
  • keyPressDelayRangetypeSpeed
  • sentenceDelayPerCharRange → Use sentences + sentenceDelay props
  • blinkAnimationDurationblinkSpeed
  • type() render-prop now returns explicit action objects instead of mixed arrays
  • New: useTypewriter hook, deleteChars, loop, mistakeChance, callbacks