dactylo

dactylo

Typewriter effect in JS using CSS.

By Rémino Rem
https://remino.net/

Docs | Code Repo | npm Package



Installation

npm install dactylo

Back to top


Usage

Apply the effect automatically:

import 'dactylo/auto'

Or call it yourself:

import { dactylo } from 'dactylo'

dactylo(document.body)

Or configure the groups yourself:

dactylo({
    root: document.querySelector('main'),
    caret: '_',
    prompt: '>',
    startDelay: 600,
    groups: [
        {
            sels: 'h1, h2',
            duration: 600,
        },
        {
            sels: 'p, li',
            interval: 18,
            parallel: true,
        },
    ],
})

Back to top


Options

Each group accepts:

Add data-dactylo-skip to any element that should not be processed.

Back to top


API

const controller = dactylo(document.body)

await controller.finished
controller.reset()

The finished promise resolves after all groups complete. The reset() method restores any element that is still typing.

Back to top


Development

npm install
npm run dev
npm run build

The library source lives in src/lib. The documentation site is built with Astro and lives in the rest of src.


Contributing

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature/amazing-feature.
  3. Make your changes.
  4. Run npm run build.
  5. Commit, push, and open a pull request.

Issues and ideas are welcome.

Back to top


Licence

Licensed under the ISC licence. See LICENSE.md.

Back to top