
Making React Titles Easier to Read
M. Zakyuddin Munziri
@zakiego
Originally written in Bahasa Indonesia.
Introduction
Let's get acquainted with React Wrap Balancer. In short, this library helps make titles more pleasant to read. How does it work?
Before

After

Notice how the word "meeting" that was previously alone on its own line is no longer isolated. The text composition becomes more evenly distributed.
As stated in its documentation,
"React Wrap Balancer avoids single hanging word on the last line"
Discussion
Actually, you don't have to use the React Wrap Balancer library. Another approach is to use the CSS text-wrap: balance property, but you need to be careful because not all browsers support this feature yet.
Therefore, it's safer to use React Wrap Balancer. It will use text-wrap: balance when possible, and if not, it will use its own method.
How to Use
First, install the library. Oh, and don't forget to use pnpm.
pnpm add react-wrap-balancer
# or
npm install react-wrap-balancer
# or
yarn add react-wrap-balancer
Import the library.
import Balancer from "react-wrap-balancer";
Finally, wrap your text inside <Balancer>.
<h1>
<Balancer>Humans Are Forgetful, Take Notes of Your Meetings</Balancer>
</h1>
This library is not limited to titles only; it can also be used for other tags as needed.


