Skip to content

API Reference

SplitText

Wrap your text with this component. The text will automatically be wrapped, by default with span elements, and will be readjusted on resize.

<SplitText>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat
</SplitText>

Props

NameDescriptionType
classNameclassName to forward to the container.string
styleA style object to forward to the container.CSSProperties
LineWrapperA custom component to wrap each split line.ComponentType<LineWrapperProps>
WordWrapperA custom component to wrap each split word.ComponentType<WordWrapperProps>
LetterWrapperA custom component to wrap each split letter.ComponentType<LetterWrapperProps>
extraPropsAn extra value that will be forwarded to each wrapper.T
childrenThe content to be split and rendered.ReactNode
debounceTimeThe time the resize listener should be debounced by. In milliseconds.number
tagThe HTML tag as the container for the text.HTMLElementTag

Example

You can inspect the bellow result to see how each line, word and letter are wrapped with a span.

TODO: add live code example

LineWrapper

Creates a custom line wrapper for SplitText. It receives the following props:

Props

NameDescriptionType
lineIndexThe current index of the line.number
extraPropsExtra props forwarded from SplitText.T
childrenReactNode

Example

Hover the lines to see their indexes.

TODO: add live code example

WordWrapper

Creates a custom word wrapper for SplitText. It receives the following props:

Props

NameDescriptionType
lineIndexThe current line index where the word wrapper lives.number
wordIndexThe current index of the word.number
countIndexThe current index of the total wrapped words inside SplitText.number
extraPropsExtra props forwarded from SplitText.T
childrenReactNode

Example

Hover the words to see their indexes.

TODO: add live code example

LetterWrapper

Creates a custom letter wrapper for SplitText. It receives the following props:

Props

NameDescriptionType
lineIndexThe current line index where the letter wrapper lives.number
wordIndexThe current word index where the letter wrapper lives.number
letterIndexThe current index of the letter.number
countIndexThe current index of the total wrapped letters inside SplitText.number
extraPropsExtra props forwarded from SplitText.T
childrenReactNode

Example

Hover the letters to see their indexes.

TODO: add live code example