Ok, this is *very* cool. “React Wrap Balancer”, a React component for creating balanced text. By @shuding_ at @vercel.

Avoid awkward hanging characters ("widows") by wrapping text in a <Balancer> component.

react-wrap-balancer.vercel.app
With stuff like this, my first thought is always “But what about SSR?”.

Packages like this typically run on the client, *after* rehydration. This leads to an awkward flicker where the text "rebalances" a second or two after the page loads.

This package works flawlessly 💯
It works by inlining a script in the HTML, similar to the technique I share in “The Quest for the Perfect Dark Mode” (joshwcomeau.com/react/dark-mod…).

It's very clever. @shuding_'s work is always immaculate.
Hopefully in the future, text balancing will be supported natively in the browser, and we won't need clever workarounds like this. But in the meantime, this is the best tool I've seen for solving this problem in a React context 💯

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Josh W. Comeau

Josh W. Comeau Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @JoshWComeau

Dec 29
The fun thing about Blender is that once you have the models, it's relatively easy to tweak the camera/lighting and create *glamor shots*.

🧵 Here are 4 of my favourites!
This one is taken at a sharper angle, and has depth of field. The focus point is set on that black knob near the center.

The glowing pink/yellow squares in the top-right aren't normally visible, but they cast light onto the visible modules. photo-realistic shot of a 3...
This one's at another angle!

That pink/yellow grid in the back is also not typically visible, but provides ambient lighting for the modules along the top. Another shot of the same ma...
Read 7 tweets
Dec 29
🌠 Over the past few months, I've discovered a couple products that have helped me stay focused during the day, and get good sleep at night.

I wanna tell you about them! 🧵
I should say first: this isn't a sponsored post. I'm not being compensated in any way. The companies don't know I'm posting this. There are no affiliate links.

I just genuinely want to share stuff I've found helpful, in case it helps you too!
The first is Magic Mind (magicmind.co). It's a “productivity drink”.

It has a more subtle effect than their marketing suggests (for me, at least ), but I have actually found it helps me focus.
Read 18 tweets
Dec 11
So, 2022 is almost over, which means your professional development stipend is about to expire! ⏰

If you work at a company that has this perk, I've collected some suggestions in this thread! Books and courses I've been impressed with, or excited by.
Sarah Drasner recently published a book, "Engineering Management for the Rest of Us"! If you're thinking about exploring eng management, there's nobody I'd rather learn from.

Plus, it shows your employer that you're looking to grow your career. 😄

I'm a big fan of @steveschoger + @adamwathan's "Refactoring UI". It's a collection of tips to help developers sharpen their design sense, and avoid all of the common mistakes we tend to make.

Read 12 tweets
Dec 9
So ~13 years ago, I was at a department store, and they had a promotion: Sign up for their credit card, get $50 off your first purchase.

I was buying a $70 thing, so I went ahead and got it for $20, put on my new credit card.

This was a mistake.

🧵
From what I remember, I paid off the $20 within a couple of weeks, destroyed the card, and forgot all about it.

~10 years later (!!), I get a letter from a collections agency. I owe many hundreds of dollars for unpaid credit card bills.
It took a lot of work to track down, since the bill had bounced between different collection agencies, but I eventually figure out what the original charge was.

I had paid off the card in full, but a tiny amount of interest had accumulated. Like, a few cents.
Read 10 tweets
Nov 22
✨ Introducing: “An Interactive Guide to Flexbox” ✨

It's a brand new interactive blog post with 20+ demos that help you build an intuition for how Flexbox works. 🔥

I've never been more excited about a blog post 😄

→ Check it out:
joshwcomeau.com/css/interactiv…
When you get comfortable with Flexbox, you can build some truly remarkable things. Check out this demo, heavily inspired by @argyleink’s “4 layouts for the price of 1”.

It uses *no media queries*! It's all based on fluid principles.
Demos like this used to hurt my brain. I *thought* I understood Flexbox, but I couldn't fathom how stuff like this worked!

Fast-forward a few years, and a LOT of practice, and I use these techniques in my work every day.
Read 5 tweets
Nov 21
So, I have some news! 😮

My signature CSS course, CSS for JavaScript Developers, just went on sale for Black Friday.🎈

You can now pick up the full course for ✨ 50% off ✨ the standard price!

Check it out: css-for-js.dev
Or, learn more in thread 🧵
I started tinkering with CSS back in 2007. For a decade, I stumbled my way through it. I was able to get stuff done, but I wasn't confident.

I had my go-to snippets, things I could copy/paste to solve specific problems, but sometimes they didn't work and I didn't know why. 😬
I decided that I was sick of struggling with CSS, and so I started actively trying to understand it. When I'd run into some funky behaviour, I'd settle into the problem like a warm bath, and work through it until I understood.
Read 13 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(