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

split-text-react

v0.0.2

Published

Helps you create beautiful text animations by splitting and wrapping your text into lines, words and letters with a custom element.

Downloads

7

Readme

Split Text React

Helps you create beautiful text animations by splitting and wrapping your text into lines, words and letters with a custom element.

Want to see the library in action? Check out these awesome Demos. If you're ready to get started, visit the Installation Guide and the API Documentation.

Standout Features

  • Fully Responsive 📐: recalculates wrappers on component resize with ResizeObserver, rather than on window resize.
  • Lightweight 🪶: zero dependencies, and less than 7kb un-minified.
  • Semantic 📝: wraps you text in span by default, so you can use it inside h1 and many other elements. You can also select the container's rendered container tag via props.

Installation

You can get started by running the following command

npm i split-text-react

That's it! You can now import the component and the types. Checkout the API Documentation to learn how to use them

import SplitText {
  SplitTextProps,
  LineWrapperProps,
  WordWrapperProps,
  LetterWrapperProps,
} from 'split-text-react';

export default function Component() {
    return <SplitText>This is awesome!</SplitText>
}

Deep Dive

In the following sections I'll explain some aspects of the library I think you might want to be aware of when using the library. You're completely free to give them a miss, but taking a look would at them would help you understand the library better

The ResizeObserver

This is the web API that allows SplitText to only re-calculate the wrappers when it has actually been resized, rather than listening to the window's resize event. You can check the MDN documentation for this API here.

Although it sits at 96.17% support on caniuse.com at the moment of writing this README, if you ever encounter issues with compatibility you can install the resize-observer-polyfill to patch this API.

The default wrappers

If you've used GSAP's SplitText before, you'd probably noticed we're using span elements rather than div. This is intentional, as span elements can be children of basically any HTML element due to them being inline by default. However, we're setting their display property to inline-block to avoid issues with the transform property in some browsers.

Acknowledgments

  • @CyriacBr: This package was inspired/forked from react-split-text (hence this package's super creative name). Thank you for building this awesome library! ❤️
  • The GSAP team: More specifically the SplitText's features section. It helped me figure out the issues I was having with span elements. If you're building animations with this package, definitely checkout gsap. It's one of the best animation libraries out there.