1.0.12 • Published 11 months ago

typewriting-react v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

A simple typing animation in React.

npm GitHub stars gzip size Travis (.org) npm

rt

Installation

$ npm install typewriting-react

or

$ yarn add typewriting-react

Usage

import React from 'react';

import { Typewriter } from 'typewriting-react';

function App() {
  return (
    <div className="App">
      <Typewriter words={['Developer', 'UX Designer']} />
    </div>
  );
}

export default App;

toggle

API

PropTypeDefaultDescription
wordsarrayRequiredArray of strings to be animated
loopbooltrueThe animation loop
typingSpeednumber50Typing speed in milliseconds
erasingSpeednumber100Erasing speed in milliseconds
nextWordDelaynumber2000Time delay before erasing
onWordFinishTypingfunc() => {}Called after typing each word, with index of the current word
onFinishedfunc() => {}Called after typing all words in the array
cursorStyleobject{}Cursor style
styleobject{}Text style
classNamestringText css class name
cursorClassNamestringCursor css class name

Styling cursor using css

simple css cursor style

.cursor {
  background: lime;
  line-height: 17px;
  margin-left: 3px;
  animation: blink 0.8s infinite;
  width: 7px;
  height: 15px;
  display: inline-block;
}

@keyframes blink {
  0% {background: #222}
  50% {background: lime}
  100% {background: #222}
}
import React from 'react';

import { Typewriter } from 'typewriting-react';

// import css file

import './cursor.css';

function App() {
  return (
    <div className="App">
      <Typewriter cursorClassName='cursor' words={['Developer', 'UX Designer']} />
    </div>
  );
}

export default App;

toggle

Advanced usage

import React, {useState}> from 'react';

import { Typewriter } from 'typewriting-react';

import {
  Table
} from 'ds-react-table';

function App() {
  const [headers, setHeaders] = useState([]);
  const [index, setIndex] = useState(0);
  const [tableData] = useState([...]);

  return (
    <>
      <div className='container'>
        <Typewriter
          className='sql-statement'
          cursorClassName='cursor'
          loop={true}
          onWordFinishTyping={(idx) => {
            setIndex(idx);
            setHeaders(createHeaders(tableData[idx]));
          }}
          words={words}
        />
      </div>
      <Table headers={headers} data={tableData[index]} />
    </>
  );
});

toggle

License

MIT

1.0.9

11 months ago

1.0.11

11 months ago

1.0.10

11 months ago

1.0.12

11 months ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago