1.1.8 • Published 1 year ago

react-text-typist v1.1.8

Weekly downloads
122
License
MIT
Repository
github
Last release
1 year ago

npm npm size npm type definitions npm downloads github last commit github contributors npm.io dependency npm.io

A simple React component to create typing animations with multiple sentences.

I you need a typing effect on your app this package may be what you need :)

Install

npm install react-text-typist --save

Demos

Demo Website

Basic Usage

import React from 'react';
import Typist from 'react-text-typist';

export default App() => {
    return (
      <Typist sentences={['First Sentence', 'Second Sentence', 'Third Sentence']} loop={false} />
    );
}

Props

Typist accepts some props to customize the component behaviour:

PropertyTypeDefaultDescriptionRequired
sentencesstring[]Array of sentences to typeyes
classNamestringClassname to customize componentno
cursorClassNamestringClassname to customize cursorno
cursorBlinkSpeedstring700 (ms)Duration of cursor blink animationno
cursorColorstringColor of cursorno
cursorSmoothbooleanfalseCursor smooth animationno
showCursorbooleantrueHide or show cursorno
typingSpeednumber80 (ms)Typing speed (ms between each character)no
deletingSpeednumber30 (ms)Deleting speed (ms between each character)no
pauseTimenumber1000(ms)Pause between sentencesno
startDelaynumber0(ms)Delay before start typingno
cursorDelaynumbersame as startDelayDelay before showing cursor for first timeno
loopbooleantrueChoose if you want infinite loopno
styleCSSProperties{}Inline CSS to apply to the componentno
defaultTextstring''Default text to render, useful with SSRno
onTypeFinishFunctionCallback when finished typingno

Customization

You can apply your own class to the text and the cursor using the 'className' prop. Also you can select the cursor in CSS via the 'typist-cursor' class or you can apply your own class just to the cursor using the 'cursorClassName' prop.

export default App() => {
    return (
      <Typist className={'myTypist'} cursorClassName={'myCursor'} sentences={['First Sentence', 'Second Sentence', 'Third Sentence']} loop={false} />
    );
}
/* Default cursor class */
.typist-cursor {
  font-size: 16px;
  color: red;
}
/* This will apply to text and cursor */
.myTypist {
  font-size: 16px;
  color: red;
}

/* This will apply only to cursor */
.myCursor {
  font-size: 16px;
  color: red;
}

The component is also compatible with libraries like 'styled-components':

import React from 'react';
import Typist from 'react-text-typist';
import styled, { createGlobalStyle } from 'styled-components';

const StyledTypist = styled(Typist)`
  font-size: 4rem;
  color: blue;
`;

export default App() => {
    return (
      <StyledTypist sentences={['First Sentence', 'Second Sentence', 'Third Sentence']} loop={false} />
    );
}
1.1.8

1 year ago

1.1.7

1 year ago

1.1.1

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.1.0

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago