1.2.0 • Published 5 months ago
react-natural-typing-effect v1.2.0
React-Natural-Typing-Effect
About
This is a very simple and small React/Typescript component library made to display a string's characters as Span elements within a Div element using a natural-feeling typing animation that is straight-forwardly configurable and stylable.
Usage
In your terminal:
npm install --save react-natural-typing-effect
In your code:
import Typer from "react-natural-typing-effect";
<Typer text="This text will be typed." />
Props
text
:- Type:
string
. - Default: none.
- Required.
- The string to render with a natural typing effect.
- Type:
isVisible
:- Type:
boolean
. - Optional.
- Default:
true
. - Whether the component is visible or not.
- Type:
customTypingOptions
:- Type:
CustomTypingOptions
.{ ms: number, pow: number, ... }
.
- Optional and all options are also optional.
- Default: none.
- Options:
ms
- Type:
number
. - Optional.
- Default:
20
. - Milliseconds.
- Type:
pow
- Type:
number
. - Optional.
- Default:
2
. - The exponent to skew to shorter (greater exponent) or longer (smaller exponent) intervals.
- Type:
mode
- Type:
string
. - Optional.
- Default:
typewriter
. - Built in modes are:
typewriter
black text, white background, black typing head (default).negativeTypewriter
white text, black background, white typing head.blackGreenTerminal
green text, black background, solid green cursor at end of line.
- Type:
cursorAtEndOfLine
- Type:
boolean
. - Optional.
- Default:
false
unless the built-in modeblackGreenTerminal
is used. - Adds a cursor-like Span element at the end of the text.
- Note: if set to
true
and modeblackGreenTerminal
is not used then an unused CSS class name calledreact-natural-typing-effect-cursor
is added to the cursor Span element.
- Type:
blinkingCursor
- Type:
boolean
. - Optional.
- Default:
false
. - Adds a blinking effect to the cursor. Only works if
cursorAtEndOfLine
is alsotrue
.
- Type:
typerCharacterClass
:- Type:
string | string[]
. - Optional.
- Default:
''
empty string. - Child component (Span element) CSS classes.
- Type:
typerCharacterInlineStyle
:- Type:
CSSProperties
. - Optional.
- Default:
{}
empty object. - Child component (Span element) CSS classes.
- Type:
clearBuiltinStyle
- Type:
boolean
. - Optional.
- Default: none.
- Removes any built-in CSS classes.
- Type:
- Type:
typerContainerClass
:- Type:
string | string[]
. - Optional.
- Default:
''
empty string. - Parent component (Div element) CSS classes.
- Type:
typerContainerInlineStyle
:- Type:
CSSProperties
. - Optional.
- Default:
{}
empty object. - Parent component (Div element) in-line styling.
- Type:
Gifs of it working
typewriter
mode:
negativeTypewriter
mode:
blackGreenTerminal
mode: