Animated typing in ~2.6 kb π‘ with React Hook.
Live Demo β¨ https://use-typical.vercel.app
yarn add use-typicalOr you can:
npm install use-typicalYou can create typing animate effects by the react hook useTypical
import React from 'react';
import useTypical from 'use-typical';
export default () => {
const ref = useTypical({
steps: ['Hello', 1000, 'Hello world!', 500],
loop: Infinity,
speed: 60,
});
return <p ref={ref}></p>;
};To display the blink effects, you can add the classname typingWrapper on the dom.
-<p ref={ref}></p>
+<p ref={ref} className="typingWrapper"></p>Such as a blink cursor style like this.
.typingWrapper::after {
content: '|';
animation: blink 1s infinite step-start;
}
@keyframes blink {
50% {
opacity: 0;
}
}const ref = useTypical(options: Options);| Params | Description | Type |
|---|---|---|
| ref | The ref of typical text wraper | React.RefObject<HTMLDocument> |
| Params | Description | Type | Default |
|---|---|---|---|
| steps | Step array assign to the typing | Array<string, number, Function> |
- |
| loop | The number of loop typing animation effect, Infinity | number |
1 |
| speed | The speed of typing animation effect | number |
60 |
Install dependencies,
$ npm iStart the dev server,
$ npm startBuild documentation,
$ npm run docs:buildBuild library via father-build,
$ npm run build