Helper for splitting and wrapping each word/letter of text/html with a span tag
npm install @pxjam/text-splitterA < 1Kb helper for splitting and wrapping each word/letter of text/html
with a span tag with custom class and computable styles.
It does not use DOM API, so it can be used outside
the browser (e.g. in Node.js for SSR).
``shell`
npm install @pxjam/text-splitter
` This is a HTML text that will be split into separate lines, words, and letters.html`
`js
import { TextSplitter } from '@pxjam/text-splitter'
const el = document.getElementById('p')
const letters = textSplitter(el.innerHTML, {
wordCls: 'W',
letterCls: 'L',
getWordStyle: (idx) => transform: translateY(${idx * 5}px),transform: translateX(${idx * 10}px)
getLetterStyle: (idx) =>
})
el.innerHTML = letters
``
https://pxjam.github.io/text-splitter/