New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@chrisfieldsii/react-use-typewriter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chrisfieldsii/react-use-typewriter

A configurable react hook for a typewriter effect. Includes a Typewriter component out the box.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

React Use Typewriter

A configurable react hook for a typewriter effect. Includes a Typewriter component out the box. Forked from react-simple-typewriter

NPM JavaScript Style Guidenpm bundle sizeGitHub

screenshot

Install

# npm
npm i @chrisfieldsii/react-use-typewriter

# Yarn
yarn add @chrisfieldsii/react-use-typewriter

Usage (Hook)

import { useTypewriter } from '@chrisfieldsii/react-use-typewriter'

const CustomSimpleTypewriter = () => {
  const text = useTypewriter({
    words: ['i', 'use', 'hooks!'],
    loop: true,
    onLoop: (loopCount) => console.log(`Hook completed loop ${loopCount}`),
    onDone: () => console.log('Done!')
  })

  return <span>{text}</span>
}

Hook Configuration (see props table below for descriptions)

interface TypewriterConfig {
  words: string[]
  loop?: boolean = false
  typeSpeed?: number = 100
  deleteSpeed?: number = 50
  delaySpeed?: number = 1500
  onLoop?: (loopCount: number) => void = noop // only called if loop = true
  onDone?: () => void = noop // only called if loop = false
}

Usage (Component)

import React from 'react'

import { Typewriter } from '@chrisfieldsii/react-use-typewriter'
import '@chrisfieldsii/react-use-typewriter/dist/index.css'

export default function App() {
  return (
    <div className='App'>
      <h1
        style={{ paddingTop: '5rem', margin: 'auto 0', fontWeight: 'normal' }}
      >
        Life is simple{' '}
        <span style={{ color: 'red', fontWeight: 'bold' }}>
          {/* Style will be inherited from the parent element */}
          <Typewriter
            loop
            cursor
            cursorStyle='_'
            typeSpeed={70}
            deleteSpeed={50}
            delaySpeed={1000}
            words={['Eat', 'Sleep', 'Code', 'Repeat!']}
            onLoop={(loopCount) =>
              console.log(`Just completed loop ${loopCount}`)
            }
          />
        </span>
      </h1>
    </div>
  )
}

Available Props

PropTypeDescriptionDefault
loopBooleanRepeat the typing effect (true if present)false
cursorBooleanShow / Hide cursor (show if present)false
cursorStyleStringChange the cursor style|
typeSpeedIntegerSpeed in Milliseconds100
deleteSpeedIntegerWord deleting speed in Milliseconds50
delaySpeedIntegerDelay after the word is written in Milliseconds1500
wordsArrayArray of strings holding the wordsrequired
onLoop(loopCount: Integer) => voidCalled when a loop is complete. loopCount is the total number of completed loops. Only called if loop = truenoop
onDone() => voidCalled when typewriter is done. Only called if loop = falsenoop

License

MIT © ChrisLFieldsII

Keywords

typewriter

FAQs

Package last updated on 25 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts