npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tailwind-plugin-typed

v0.7.0

Published

A plugin for Tailwind CSS to generate text typing animations.

Downloads

137

Readme

tailwind-plugin-typed

GitHub Actions Workflow Status GitHub Tag NPM Version Tailwind Play

A plugin for Tailwind CSS to generate text typing animations.

See it in action in the live demo on Tailwind Play

📦 Installation

Install the package with your preferred package manager (e.g. npm)

npm i -D tailwind-plugin-typed

Add the plugin to your tailwind configuration (e.g. tailwind.config.js)

/** @type {import('tailwindcss').Config} */
module.exports = {
  // ... other tailwind config
  plugins: [
    // ... other plugins
    require('tailwind-plugin-typed'),
  ],
}

⚙️ Options

This plugin exposes some optional options that can be passed in the tailwind configuration

/** @type {import('tailwindcss').Config} */
module.exports = {
  // ... other tailwind config
  plugins: [
    // ... other plugins
    require('tailwind-plugin-typed')({
      delimiter: ';',
      typeLetterDuration: 0.1,
      pauseAfterWordDuration: 2,
      deleteLetterDuration: 0.05,
      pauseAfterDeletionDuration: 1,
    }),
  ],
}

| name | description | default | |------------------------------|-------------------------------------------------------|---------| | delimiter | character on which strings are split | ; | | typeLetterDuration | duration in seconds for typing one single character | 0.1 | | pauseAfterWordDuration | pause in seconds after one whole string is typed | 2 | | deleteLetterDuration | duration in seconds for deleting one single character | 0.05 | | pauseAfterDeletionDuration | pause in seconds after one whole string is deleted | 1 |

💻 Usage

This plugin utilises arbitrary values of Tailwind CSS on the base class typed to generate a typing animation with CSS.

caret

This generates a blinking caret in an ::after pseudo element.

<p class="typed-caret">Typed</p>

single string

This generates an infite looping typing and deleting animation of the string world.

<p>Hello <span class="typed-[world] typed-caret"></span></p>

multiple strings

This generates a typing and deleting animation of multiple words one after another. The default delimiter of strings is ; but can be configured in the plugin options.

<p>This is <span class="typed-[cool;awesome;superb] typed-caret"></span></p>

sentences

One or multiple sentences can be typed as well. Just write an underscore _ instead of a space as decribed in the tailwind docs.

<p class="typed-[This_can_type_sentences.;And_then_delete_them…] typed-caret"></p>

adjust the caret

There are utilities typed-caret-color, typed-caret-width and typed-caret-space to adjust the caret.

<p>Caret <span class="typed-[color;width;space] typed-caret typed-caret-color-emerald-400 dark:typed-caret-color-emerald-600 typed-caret-width-4 typed-caret-space-2"></span></p>

escaping the delimiter and special chars

The delimiter can be escaped with a backslash \ in front of it. Then it will be typed out normally. If other reserved characters (e.g. colon :) should be typed, the whole arbitrary value can be wrapped in backticks ` which will be removed automatically

<p class="typed-[`semi:_true\;;semi:_false\;`] typed-caret"></p>

♿️ Notes on a11y

This plugin adds alternative text to the content of the pseudo element upon typing so that screen readers can hopefully read the whole text that is being typed at all times and are not affected by the animation.

Tailwind itself provides modfiers to adjust for the users preference regarding reduced motion.

This example will render a typing animation of the string no preference in case the user does not specify a preferences for reduced motion. In case the users preferes to have an experience with reduced motion the static text reduce will be rendered.

<p>
  prefers-reduced-motion:
  <span class="motion-safe:typed-[no_preference] motion-safe:typed-caret"></span>
  <span class="motion-safe:hidden">reduce</span>
</p>

💕 Thanks

This project is heavily inspired by other awesome projects like: