Installations
npm install typewriter-effect
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
18.17.1
NPM Version
9.6.7
Score
85.2
Supply Chain
92.9
Quality
75.4
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Languages
JavaScript (100%)
Developer
Download Statistics
Total Downloads
6,705,628
Last Day
4,262
Last Week
49,430
Last Month
283,749
Last Year
3,254,947
GitHub Statistics
2,506 Stars
144 Commits
224 Forks
19 Watching
4 Branches
17 Contributors
Bundle Size
29.89 kB
Minified
9.30 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.21.0
Package Id
typewriter-effect@2.21.0
Unpacked Size
232.68 kB
Size
60.67 kB
File Count
8
NPM Version
9.6.7
Node Version
18.17.1
Publised On
19 Sept 2023
Total Downloads
Cumulative downloads
Total Downloads
6,705,628
Last day
-67.8%
4,262
Compared to previous day
Last week
-30.3%
49,430
Compared to previous week
Last month
-2.2%
283,749
Compared to previous month
Last year
75.4%
3,254,947
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
21
TypewriterJS v2
NPM Repository JSFiddle Example Emoji Example
CDN
You can use the CDN version of this plugin for fast and easy setup.
1<script src="https://unpkg.com/typewriter-effect@latest/dist/core.js"></script>
Installation
You can install Typewriterjs with just one command and you're good to go
1 2# with npm 3npm i typewriter-effect 4 5# with yarn 6yarn add typewriter-effect 7
Building
You will need to bundle the javascript before it can be used, this can be done using npm run build:dev
for development or npm run build:prod
for production.
Core
This is the base version of the typewriter effect. It will need a the bundled version of the javascript to work correctly.
See examples in the 'examples' folder.
1import Typewriter from 'typewriter-effect/dist/core'; 2 3new Typewriter('#typewriter', { 4 strings: ['Hello', 'World'], 5 autoStart: true, 6});
Options
Name | Type | Default value | Description |
---|---|---|---|
strings | String or Array | null | Strings to type out when using autoStart option |
cursor | String | Pipe character | String value to use as the cursor. |
delay | 'natural' or Number | 'natural' | The delay between each key when typing. |
deleteSpeed | 'natural' or Number | 'natural' | The delay between deleting each character. |
loop | Boolean | false | Whether to keep looping or not. |
autoStart | Boolean | false | Whether to autostart typing strings or not. You are required to provide strings option. |
pauseFor | Number | 1500 | The pause duration after a string is typed when using autostart mode |
devMode | Boolean | false | Whether or not to display console logs. |
skipAddStyles | Boolean | Skip adding default typewriter css styles. | |
wrapperClassName | String | 'Typewriter__wrapper' | Class name for the wrapper element. |
cursorClassName | String | 'Typewriter__cursor' | Class name for the cursor element. |
stringSplitter | Function | String splitter function, can be used to split emoji's | |
onCreateTextNode | Function | null | Callback function to replace the internal method which creates a text node for the character before adding it to the DOM. If you return null, then it will not add anything to the DOM and so it is up to you to handle it. |
onRemoveNode | Function | null | Callback function when a node is about to be removed. First param will be an object { node: HTMLNode, charater: string } |
Methods
All methods can be chained together.
Name | Params | Description |
---|---|---|
start | - | Start the typewriter effect. |
stop | - | Stop the typewriter effect. |
pauseFor | ms Time to pause for in milliseconds | Pause for milliseconds |
typeString | string String to type out, it can contain HTML tags | Type out a string using the typewriter effect. |
pasteString | string String to paste out, it can contain HTML tags | Paste out a string. |
deleteAll | speed Speed to delete all visibles nodes, can be number or 'natural' | Delete everything that is visible inside of the typewriter wrapper element. |
deleteChars | amount Number of characters | Delete and amount of characters, starting at the end of the visible string. |
callFunction | cb Callback, thisArg this Object to bind to the callback function | Call a callback function. The first parameter to the callback elements which contains all DOM nodes used in the typewriter effect. |
changeDeleteSpeed | speed Number or 'natural' | The speed at which to delete the characters, lower number is faster. |
changeDelay | delay Number or 'natural' | Change the delay when typing out each character |
Examples
Basic example
1var app = document.getElementById('app');
2
3var typewriter = new Typewriter(app, {
4 loop: true,
5 delay: 75,
6});
7
8typewriter
9 .pauseFor(2500)
10 .typeString('A simple yet powerful native javascript')
11 .pauseFor(300)
12 .deleteChars(10)
13 .typeString('<strong>JS</strong> plugin for a cool typewriter effect and ')
14 .typeString('<strong>only <span style="color: #27ae60;">5kb</span> Gzipped!</strong>')
15 .pauseFor(1000)
16 .start();
Custom text node creator using callback
1var app = document.getElementById('app');
2
3var customNodeCreator = function(character) {
4 return document.createTextNode(character);
5}
6
7var typewriter = new Typewriter(app, {
8 loop: true,
9 delay: 75,
10 onCreateTextNode: customNodeCreator,
11});
12
13typewriter
14 .typeString('A simple yet powerful native javascript')
15 .pauseFor(300)
16 .start();
Custom handling text insert using input placeholder
1var input = document.getElementById('input') 2 3var customNodeCreator = function(character) { 4 // Add character to input placeholder 5 input.placeholder = input.placeholder + character; 6 7 // Return null to skip internal adding of dom node 8 return null; 9} 10 11var onRemoveNode = function({ character }) { 12 if(input.placeholder) { 13 // Remove last character from input placeholder 14 input.placeholder = input.placeholder.slice(0, -1) 15 } 16} 17 18var typewriter = new Typewriter(null, { 19 loop: true, 20 delay: 75, 21 onCreateTextNode: customNodeCreator, 22 onRemoveNode: onRemoveNode, 23}); 24 25typewriter 26 .typeString('A simple yet powerful native javascript') 27 .pauseFor(300) 28 .start();
React
This includes a React component which can be used within your project. You can pass in a onInit function which will be called with the instance of the typewriter so you can use the typewriter core API.
1import Typewriter from 'typewriter-effect'; 2 3<Typewriter 4 onInit={(typewriter) => { 5 typewriter.typeString('Hello World!') 6 .callFunction(() => { 7 console.log('String typed out!'); 8 }) 9 .pauseFor(2500) 10 .deleteAll() 11 .callFunction(() => { 12 console.log('All strings were deleted'); 13 }) 14 .start(); 15 }} 16/>
Alternatively you can also pass in options to use auto play and looping for example:
1import Typewriter from 'typewriter-effect'; 2 3<Typewriter 4 options={{ 5 strings: ['Hello', 'World'], 6 autoStart: true, 7 loop: true, 8 }} 9/>
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/publish-npm.yaml:8
Reason
6 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-npm.yaml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/tameemsafi/typewriterjs/publish-npm.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-npm.yaml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/tameemsafi/typewriterjs/publish-npm.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yaml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/tameemsafi/typewriterjs/tests.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yaml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/tameemsafi/typewriterjs/tests.yaml/main?enable=pin
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
- Info: 2 out of 2 npmCommand dependencies pinned
Reason
Found 4/21 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/publish-npm.yaml:1
- Warn: no topLevel permission defined: .github/workflows/tests.yaml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 22 are checked with a SAST tool
Score
3.9
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More