base on A JavaScript Typing Animation Library [![Code Climate](https://codeclimate.com/github/mattboldt/typed.js/badges/gpa.svg)](https://codeclimate.com/github/mattboldt/typed.js) [![GitHub release](https://img.shields.io/github/release/mattboldt/typed.js.svg)]() [![npm](https://img.shields.io/npm/dt/typed.js.svg)](https://img.shields.io/npm/dt/typed.js.svg) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/mattboldt/typed.js/master/LICENSE.txt) <img src="https://raw.githubusercontent.com/mattboldt/typed.js/master/logo-cropped.png" width="450px" title="Typed.js" /> ### [Live Demo](http://www.mattboldt.com/demos/typed-js/) | [View All Demos](http://mattboldt.github.io/typed.js/) | [View Full Docs](http://mattboldt.github.io/typed.js/docs) | [mattboldt.com](http://www.mattboldt.com) Typed.js is a library that types. Enter in any string, and watch it type at the speed you've set, backspace what it's typed, and begin a new sentence for however many strings you've set. --- ## Installation ### CDN ```html <script src="https://unpkg.com/[email protected]/dist/typed.umd.js"></script> ``` For use directly in the browser via `<script>` tag: ```html <!-- Element to contain animated typing --> <span id="element"></span> <!-- Load library from the CDN --> <script src="https://unpkg.com/[email protected]/dist/typed.umd.js"></script> <!-- Setup and start animation! --> <script> var typed = new Typed('#element', { strings: ['<i>First</i> sentence.', '&amp; a second sentence.'], typeSpeed: 50, }); </script> </body> ``` ### As an ESModule For use with a build tool like [Vite](https://vitejs.dev/), and/or in a React application, install with NPM or Yarn. #### NPM ``` npm install typed.js ``` #### Yarn ``` yarn add typed.js ``` #### General ESM Usage ```js import Typed from 'typed.js'; const typed = new Typed('#element', { strings: ['<i>First</i> sentence.', '&amp; a second sentence.'], typeSpeed: 50, }); ``` ### ReactJS Usage ```js import React from 'react'; import Typed from 'typed.js'; function MyComponent() { // Create reference to store the DOM element containing the animation const el = React.useRef(null); React.useEffect(() => { const typed = new Typed(el.current, { strings: ['<i>First</i> sentence.', '&amp; a second sentence.'], typeSpeed: 50, }); return () => { // Destroy Typed instance during cleanup to stop animation typed.destroy(); }; }, []); return ( <div className="App"> <span ref={el} /> </div> ); } ``` More complex hook-based function component: https://jsfiddle.net/mattboldt/60h9an7y/ Class component: https://jsfiddle.net/mattboldt/ovat9jmp/ ### Use with Vue.js Check out the Vue.js component: https://github.com/Orlandster/vue-typed-js ### Use it as WebComponent Check out the WebComponent: https://github.com/Orlandster/wc-typed-js ## Wonderful sites that have used (or are using) Typed.js https://forwardemail.net https://codesignal.com https://github.com/features/package-registry https://slack.com https://envato.com https://gorails.com https://productmap.co https://www.typed.com https://apeiron.io https://git.market https://commando.io http://testdouble.com/agency.html https://www.capitalfactory.com http://www.maxcdn.com https://www.powerauth.com --- ### Strings from static HTML (SEO Friendly) Rather than using the `strings` array to insert strings, you can place an HTML `div` on the page and read from it. This allows bots and search engines, as well as users with JavaScript disabled, to see your text on the page. ```javascript <script> var typed = new Typed('#typed', { stringsElement: '#typed-strings' }); </script> ``` ```html <div id="typed-strings"> <p>Typed.js is a <strong>JavaScript</strong> library.</p> <p>It <em>types</em> out sentences.</p> </div> <span id="typed"></span> ``` ### Type Pausing You can pause in the middle of a string for a given amount of time by including an escape character. ```javascript var typed = new Typed('#element', { // Waits 1000ms after typing "First" strings: ['First ^1000 sentence.', 'Second sentence.'], }); ``` ### Smart Backspacing In the following example, this would only backspace the words after "This is a" ```javascript var typed = new Typed('#element', { strings: ['This is a JavaScript library', 'This is an ES6 module'], smartBackspace: true, // Default value }); ``` ### Bulk Typing The following example would emulate how a terminal acts when typing a command and seeing its result. ```javascript var typed = new Typed('#element', { strings: ['git push --force ^1000\n `pushed to origin with option force`'], }); ``` ### CSS CSS animations are built upon initialization in JavaScript. But, you can customize them at your will! These classes are: ```css /* Cursor */ .typed-cursor { } /* If fade out option is set */ .typed-fade-out { } ``` ## Customization ```javascript var typed = new Typed('#element', { /** * @property {array} strings strings to be typed * @property {string} stringsElement ID of element containing string children */ strings: [ 'These are the default values...', 'You know what you should do?', 'Use your own!', 'Have a great day!', ], stringsElement: null, /** * @property {number} typeSpeed type speed in milliseconds */ typeSpeed: 0, /** * @property {number} startDelay time before typing starts in milliseconds */ startDelay: 0, /** * @property {number} backSpeed backspacing speed in milliseconds */ backSpeed: 0, /** * @property {boolean} smartBackspace only backspace what doesn't match the previous string */ smartBackspace: true, /** * @property {boolean} shuffle shuffle the strings */ shuffle: false, /** * @property {number} backDelay time before backspacing in milliseconds */ backDelay: 700, /** * @property {boolean} fadeOut Fade out instead of backspace * @property {string} fadeOutClass css class for fade animation * @property {boolean} fadeOutDelay Fade out delay in milliseconds */ fadeOut: false, fadeOutClass: 'typed-fade-out', fadeOutDelay: 500, /** * @property {boolean} loop loop strings * @property {number} loopCount amount of loops */ loop: false, loopCount: Infinity, /** * @property {boolean} showCursor show cursor * @property {string} cursorChar character for cursor * @property {boolean} autoInsertCss insert CSS for cursor and fadeOut into HTML <head> */ showCursor: true, cursorChar: '|', autoInsertCss: true, /** * @property {string} attr attribute for typing * Ex: input placeholder, value, or just HTML text */ attr: null, /** * @property {boolean} bindInputFocusEvents bind to focus and blur if el is text input */ bindInputFocusEvents: false, /** * @property {string} contentType 'html' or 'null' for plaintext */ contentType: 'html', /** * Before it begins typing * @param {Typed} self */ onBegin: (self) => {}, /** * All typing is complete * @param {Typed} self */ onComplete: (self) => {}, /** * Before each string is typed * @param {number} arrayPos * @param {Typed} self */ preStringTyped: (arrayPos, self) => {}, /** * After each string is typed * @param {number} arrayPos * @param {Typed} self */ onStringTyped: (arrayPos, self) => {}, /** * During looping, after last string is typed * @param {Typed} self */ onLastStringBackspaced: (self) => {}, /** * Typing has been stopped * @param {number} arrayPos * @param {Typed} self */ onTypingPaused: (arrayPos, self) => {}, /** * Typing has been started after being stopped * @param {number} arrayPos * @param {Typed} self */ onTypingResumed: (arrayPos, self) => {}, /** * After reset * @param {Typed} self */ onReset: (self) => {}, /** * After stop * @param {number} arrayPos * @param {Typed} self */ onStop: (arrayPos, self) => {}, /** * After start * @param {number} arrayPos * @param {Typed} self */ onStart: (arrayPos, self) => {}, /** * After destroy * @param {Typed} self */ onDestroy: (self) => {}, }); ``` ## Contributing ### [View Contribution Guidelines](./.github/CONTRIBUTING.md) ## end Thanks for checking this out. If you have any questions, I'll be on [Twitter](https://twitter.com/atmattb). If you're using this, let me know! I'd love to see it. It would also be great if you mentioned me or my website somewhere. [www.mattboldt.com](http://www.mattboldt.com) ", Assign "at most 3 tags" to the expected json: {"id":"7460","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"