Coder Social home page Coder Social logo

marcreichel / alpine-typewriter Goto Github PK

View Code? Open in Web Editor NEW
102.0 1.0 3.0 134 KB

Little Alpine.js plugin to add a typewriter effect to any HTML element.

License: MIT License

JavaScript 100.00%
alpinejs alpinejs-plugin plugin typewriter typewriter-animation typewriter-effect hacktoberfest

alpine-typewriter's Introduction

⌨️ Alpine Typewriter ⌨️

An Alpine.js plugin to add a typewriter effect to any HTML element.

version Build size downloads JSDelivr GitHub Gitmoji

hero

🚀 Installation

CDN

Include the following <script> tag in the <head> of your document, just before Alpine.

<script src="https://cdn.jsdelivr.net/npm/@marcreichel/alpine-typewriter/dist/alpine-typewriter.min.js" defer></script>

NPM

npm install @marcreichel/alpine-typewriter

Add the x-typewriter directive to your project by importing the package before starting Alpine.

import Alpine from 'alpinejs';
import Typewriter from '@marcreichel/alpine-typewriter';

Alpine.plugin(Typewriter);

Alpine.start();

🪄 Usage

Simply add the x-typewriter directive to any HTML element and provide the texts which should be cycled through.

<span x-data="{ texts: ['Hello', 'World'] }" x-typewriter="texts"></span>

Adjust the speed

By default, a text stays for 2 seconds before being swapped out. This behavior may be adjusted using a modifier like so:

<span x-data="{ texts: ['Hello', 'World'] }" x-typewriter.5s="texts"></span>

or

<span x-data="{ texts: ['Hello', 'World'] }" x-typewriter.3000ms="texts"></span>

Add an animated cursor

To add a blinking cursor add the cursor modifier like so:

<span x-data="{ texts: ['Hello', 'World'] }" x-typewriter.cursor="texts"></span>

📄 License

Copyright (c) 2023 Marc Reichel and contributors.

Licensed under the MIT license, see LICENSE for details.

alpine-typewriter's People

Contributors

marcreichel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

alpine-typewriter's Issues

Animated cursor possible?

Hi Marc, really like your project. Clean and simple.
I was only wondering; Is it possible to add an animated cursor: | after the each word?
Thanks!

Spacing between words

Good day. It seems like there is an issue with spacing between words. I'll try to look at it in-depth tomorrow. But just a heads up. Thanks for the package through,

Input:

image

This is the end result.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.