This is not a NPM package, this is simple snipet to copy paste it.
This code demonstrate not a perfect, but simple and useful way of how to split words in title pretty
Just copy the code below and paste it to your project.
/**
* Split text to binary tree for more beautiful text wrapping
* @example
* return <h1>{splitTitle(props.titile)}</h1>
* @see {@link github.com/artalar/splitTitle}
*/
export function splitTitle(text: string) {
if (text.length < 5 || !text.includes(" ")) {
return text;
}
const median = Math.floor(text.length / 2);
for (let step = 0; step < median; step++) {
for (const i of [median - step, median + step]) {
if (text[i] === " ") {
return (
<span style={{ display: "inline-block" }}>
{splitTitle(text.substring(0, i))}{" "}
{splitTitle(text.substring(i + 1))}
</span>
);
}
}
}
}


