Tiny Text Splitting JavaScript Library – SplitBun

Category: Javascript , Text | November 10, 2023
Author:farisphp
Views Total:44 views
Official Page:Go to website
Last Update:November 10, 2023
License:MIT

Preview:

Tiny Text Splitting JavaScript Library – SplitBun

Description:

SplitBun is a lightweight yet robust text split JavaScript library that enables effortless breaking down of text elements into lines, words, or characters.

The library handles the heavy lifting of slicing up your text while giving control over options like specifying the type of split and passing a callback when the split completes. The wrapperClass and innerClass options let you easily style the generated elements or create engaging CSS-powered text animations.

How to use it:

1. Install and import the SplitBun.

# NPM
$ npm i splitbun
import splitBun from 'splitbun'

2. Initialize the SplitBun on your text container and specify the split type: lines, words, or chars.

<div id="demo">
... text here ...
</div>
splitBun('#demo',{
  type: 'lines'
})

3. Set the CSS classes of wrapper & innner elements.

splitBun('#demo',{
  type: 'lines',
  wrapperClass: 'wrapper-ele',
  innerClass: 'inner-ele',
})

4. Execute a function after text splitting.

splitBun('#demo',{
  type: 'lines',
  onComplete: () => {
    console.log('split text completed)
  },
})

Changelog:

v1.0.13 (11/10/2023)

  • Support custom inline style

You Might Be Interested In:


Leave a Reply