1.1.6 • Published 1 year ago
react-mk v1.1.6
A light weight React component for emulating typing animations.
Install
npm i react-mk --saveNo need to import pesky CSS files, react-mk works right out of the box.
Example
Test it out on codesandbox
Instructions
- Import
Keyboardfromreact-mk Keyboardaccepts any child with a validtoStringmethodKeyboardexposes atypemethod whenchildrenis a type offunctionKeyboardwill type out your text in an organic manner, see exampleBesides
children,Keyboardcan take the following optional propssentenceDelayPerCharRange: an array of two numbers indicating the delay in milliseconds whichreact-mkapplies between words, the delay is calculated by getting a random number in your range and multiplying it by the number of characters in your sentence.keyPressDelayRange: an array of two numbers indicating the delay in milliseconds whichreact-mkapplies between characters, the delay is calculated by getting a random number in your range.
You may also import the
Cursorcomponent fromreact-mk; a standard blinking cursor that accepts the following propschildren: the cursor you wish to display, it will accept anynodeand is a|by defaultblink: a bool which istrueby default, whenfalsethe cursor will not blinkblinkAnimationDuration: theanimation-durationof thecssanimationproperty of the cursor- All other props will be spread to the root element which is a
span
Usage
import React from 'react';
import Keyboard, { Cursor } from 'react-mk';
const TypingComponent = () => (
<>
<Keyboard sentenceDelayPerCharRange={[0, 0]}>You can write whatever you like here</Keyboard>
<Cursor />
<br />
<Keyboard keyPressDelayRange={[200, 400]}>
{({ type }) =>
type(
1000,
'You can even type super slowly using the keyPressDelayRange prop',
300,
'Set the blink property of Cursor to false to disable the blinking animation --> ',
)
}
</Keyboard>
<Cursor blink={false} />
<br />
<Keyboard sentenceDelayPerCharRange={[0, 0]} keyPressDelayRange={[50, 70]}>
{({ type }) => type(3000, 'Multiple instances of Keyboard can easily be rendered at the same time')}
</Keyboard>
<Cursor>#</Cursor>
<br />
<Keyboard sentenceDelayPerCharRange={[300, 400]}>
{({ type }) =>
type(
4000,
"Use the sentenceDelayPerCharRange prop to adjust the amount of time that your sentences should be visible (It'll be a while before the next sentence appears)",
'You can also pass a number to the `type` function to dictate the time between deleting the previous sentence and writing the next sentence',
)
}
</Keyboard>
<Cursor blinkAnimationDuration={200}>[]</Cursor>
</>
);1.1.6
1 year ago
1.1.5
4 years ago
1.1.4
5 years ago
1.1.3
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.1.2
5 years ago
1.0.9
6 years ago
1.0.8
6 years ago
1.0.7
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago
0.0.18
6 years ago
0.0.17
6 years ago
0.0.15
6 years ago
0.0.14
6 years ago
0.0.13
6 years ago
0.0.12
6 years ago
0.0.11
6 years ago
0.0.10
6 years ago
0.0.9
6 years ago
0.0.8
6 years ago
0.0.7
6 years ago
0.0.6
6 years ago
0.0.5
6 years ago
0.0.4
6 years ago
0.0.3
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago