Socket
Socket
Sign inDemoInstall

svelte-typewriter

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-typewriter

A simple and reusable typewriter effect for your Svelte applications


Version published
Weekly downloads
4.7K
increased by10.47%
Maintainers
1
Weekly downloads
 
Created
Source

svelte-typewriter

A simple and reusable typewriter effect for your Svelte applications

PRs Welcome npm Version npm Downloads MadeWithSvelte.com shield

DEMO

Summary

Installation

# yarn
yarn add -D svelte-typewriter

# npm
npm i -D svelte-typewriter

Usage

You need to import the Svelte component, and wrap your elements with the <Typewriter> component

<script>
    import Typewriter from 'svelte-typewriter'
</script>

<Typewriter>
	<h1>Testing the typewriter effect</h1>
	<h2>The typewriter effect cascades by default</h2>
	<p>Lorem ipsum dolor sit amet consectetur</p>
</Typewriter>

Props

The <Typewriter> component can receive props that allows to manipulate the behavior of the resulting animation, these props are divided into 4 groups

  • Settings: general animation properties
  • Modes: different styles of animation
  • Event listeners: functions executed based on the condition of a trigger
  • Child attributes: child elements animation properties

Settings

PropTypeDescriptionDefault
intervalnumber or arrayThe interval in milliseconds between each letter, you can also pass a array of distinct intervals to mimic human typing30DEMO
unwriteIntervalnumberThe interval in milliseconds between each letter unwrite, is valid only on loops. If not defined it uses intervalfalseTBA
cursorboolean or stringEnables/disables the terminal cursor on the Typewriter animation, and also, allows you to pass any valid color name, hex code, rgb/rgba valid values to change the cursor colortrueDEMO
delaynumberThe interval in milliseconds before the animation starts0DEMO
scrambleSlowdownbooleanEnables/disables the slowdown effect right before the scramble animation ends (only works in scramble mode)true if on scramble mode, otherwise falseTBA

Modes

You can control the behavior of the typewriter effect by passing specific props to the <Typewriter> component, the table below contains information about all modes:

ModeTypeDescriptionDefault
defaultApply animation simultaneously on all elements, as opposed to the sequential animation of cascade modetrueDEMO
cascadebooleanApply animation on all elements sequentially instead of simultaneouslyfalseDEMO
loopboolean or numberCycles the animation between the children elements of the parent Typewriter component, the interval (in milliseconds) between each word can be defined by passing a number as the parameter, otherwise defaults to 1500falseDEMO
loopRandomboolean or numberIt's very similar to loop mode, but instead of cycling the animation in a linear way, it picks a random child element to animate each time, the interval (in milliseconds) between each word can be defined by passing a number as the parameter, otherwise defaults to 1500falseDEMO
scrambleboolean or numberRandomize all letters in a element text for a specific amount of time, if a number is passed as argument, it's defined as the duration of the animation (defaults to 3000)falseDEMO

Event listeners

EventTrigger
on:doneIs executed at the end of the animation, if used with loop mode, this event will be fired at the end of each loopDEMO

Child attributes

AttributeDescription
data-staticMarks an element as static, excluding it from receiving animations from the <Typewriter> component

Used by

FAQs

UMD and IIFE output formats are not supported for code-splitting builds.

From version 2.1.17 onwards, this library makes use of dynamic imports, if your Rollup configuration output.format is set to iife or umd, consider setting inlineDynamicImports to true, otherwise, change output.format to something else, like esm (for more details, consider checking #21)

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b fix/my-new-bug-fix
  3. Preview your changes with yarn dev (or npm run dev)
  4. Commit your changes: git commit -am 'fix: Fix some bug'
  5. Push to the branch: git push origin fix/my-new-bug-fix
  6. Submit a pull request :D

Keywords

FAQs

Package last updated on 28 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc