Yesterday in the Q&A portion of my conf talk, I got a question asking what I thought about CSS frameworks like Bootstrap.

My answer: I do not suggest using them. Nor do I suggest using fully-styled component libraries like Material UI.

Here’s why 👇🏻
For Christmas this year, I was gifted a Lego NES kit. Was super fun.

Here’s a question, though: what if I had been given all the blocks, but no instructions? What if I wasn’t even shown the final product?

How good would my NES look, do you think? A Nintendo Entertainment System made out of legos
A design is more than the sum of its parts. I can take a bunch of really-nicely-designed components and still wind up with a poorly-designed product.

It’s been said that only Google can produce nice-looking Material Design apps, since their designers understand how to use it.
I teach at a bootcamp, and we strongly discouraged students from using fully-styled component libraries.

Invariably, students would hit a point where they’d spend longer trying to override the styles / get it to work than they would have spent building it from scratch
Anecdotally, the students who tried using a component library like Material UI spent longer on styling, and didn’t wind up with a nicer UI.

You get off the ground quicker, but you burn so much more time trying to polish and finish the app.
Now there is one HUGE caveat here. I’m talking specifically about “styled” component libraries.

Style-agnostic libraries like Reach UI, which focus purely on functionality, are a godsend and you should absolutely use them. Please don’t build your own modal from scratch.
I think of tools like Reach UI as the “missing standard library of the DOM”. They fill in the gaps that the platform really should have natively, things like dialogs and tooltips and comboboxes. But they don’t prescribe any styles. That’s up to you.
What about Tailwind?

I’ve shared before that Tailwind isn’t my favourite tool, but I think it deftly avoids the issues I’ve been talking about here. In Tailwind you pick which utilities you use, and everything is customizable. So I don’t group it in with Bootstrap/MaterialUI.
For solo developers without design skills and limited time, it can be really tempting to grab an off-the-shelf component library. I get that.

But it’s like writing code without writing tests — it’s faster at first, until the project becomes complex. Then it slows you way down.
I think if you’re a solo dev maker, investing in your design skills is the best thing you can do. You don’t need to spend weeks becoming a design whiz - you just need to learn enough of the fundamentals to make something that looks “real enough”.
I think Refactoring UI is a fantastic resource. It’s relatively short and can go a long way.

I have plans to do some stuff in this space as well 😃 but that’s distant-future stuff.
TL;DR — unless you’re building a short-term project (prototype, hackathon), CSS frameworks can be harmful, *increasing* the amount of time you need to spend on the UI.

I recommend using a style-agnostic tool like Reach UI instead. Use third-party functionality, not styles.
Shameless 🔌: I'm working on a CSS course! It's a comprehensive guide to becoming confident with CSS.

It also features a module all about components 😄 we build our own mini component library.

Learn more: css-for-js.dev

• • •

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

1 Feb
Today I looked into the performance of different layout modes in CSS. I was curious if it takes the browser longer to lay out elements in a grid vs. Flexbox vs. flow layout.

TL:DR; they're all plenty fast ⚡️ but there are small differences.

Info in thread 👇🏻
For the benchmark, I created an app that renders 1000 random items, with a couple HTML tags in each one. I trigger a re-render, and measure how long it takes to recalculate layout.

Specifically looking for the time spent in this step: Close-up screenshot of the ...
1. Regular flow layout. No CSS on the container.

Average layout recalc time: 22.3ms

I imagine this is the lowest it could be, since each element fills the available width. No "interplay" between children.

This will be our baseline! A list of names stacked ver...
Read 16 tweets
12 Jan
🌠 Keep navigation centered in a lopsided container (logo on one side, nothing on the other) with Flexbox!

“Asymmetrical centering” like this has befuddled me for a long time, but I've cracked the code: `flex-basis` is key 🔓🗝

Demo + Code: codepen.io/joshwcomeau/pe…
When `flex-basis` is set to `0`, it distributes ALL space, not just empty space.

So: we put columns on either side of the nav, make them greedy with `flex-grow`, and distribute the space with `flex-basis`:

.column {
flex-grow: 1;
flex-basis: 0;
}

(Image credit: w3 dot org) A diagram showing how flex-basis: 0 distributes all space re
(You can also use `flex: 1` instead, but that shorthand obfuscates what's really going on here!)

Another nifty trick: The nav items "fan out" as the window gets larger, thanks to viewport-based gap sizes:

nav {
display: flex;
gap: max(calc(10vw - 60px), 16px);
} Two side-by-side screenshots of a large window and a small o
Read 6 tweets
6 Jan
Woaaah — An AI that can generate delightful illustrations from text captions.

This will be GOLD for folks who want custom illustrations to visually explain a concept. The content creator in me is *pumped*.

openai.com/blog/dall-e
Heard from some folks that are concerned about the effect it'll have on artists. Wrestling with this a bit.

In my view, it's similar to the effect that Squarespace had on web developers. There's still plenty of demand for us, but it changed a bit.
Essentially things shift upwards a bit. It's less common to get paid $500 to build a website for your local bakery, but still plenty of opportunities building dynamic products for businesses with big budgets.
Read 10 tweets
9 Dec 20
✨ This year I decided to take blogging more seriously. In 2020, I published 30 articles on my blog, joshwcomeau.com.

We're nearing the end of the year, so I thought it'd be fun to do a "Top 10" countdown, sorted by # of views 😄 I'll share some context about each one!
#10 — Boop! joshwcomeau.com/react/boop/

This animation tutorial details how I created a wobbly temporary hover state using React Spring.

I was unhappy with the hover animations on my course platform, and decided to experiment. I was so happy with the results, it became a blog post!
#9 — Embracing Modern Image Formats. joshwcomeau.com/performance/em…

A look at how to use the modern “.webp” image format to shave some KBs off your page, in a backwards-compatible way 😄

Tools like `gatsby-image` and `next/image` are making it redundant, and I'm thrilled ✨
Read 13 tweets
23 Nov 20
The most infamous CSS rule is:

button:focus {
outline: none;
}

This style removes the "ugly" focus ring on inputs and links, but it means keyboard users can't navigate; it totally breaks the experience for them (and any non-mouse users) 😬

A thread with some solutions 🧵
First, some quick options:

• Leave them as-is! Outlines aren't so bad.
• Provide an alternative focus style, like changing the background color, or adding a border.

There's a nifty new pseudo-class you may not be aware of, though…
🌠 The `:focus-visible` pseudo-class is just like the `:focus` one, but it only matches when the browser determines that a visible focus state is necessary (eg. not a mouse user).

Keyboard users will see the focus rings, but mouse users won't.
Read 6 tweets
31 Oct 20
For the past week I’ve been using the Xiaomi Redmi 8 as my main phone. It’s the most common “budget” smartphone in India.

In some ways, this thing is shockingly good. In others, downright surprising. But there were some disappointments.

🧵 My experience in-thread: ImageImageImage
For context, I ordered this phone from AliExpress. Cost me $90 USD.

It costs ₹8,000, well below the average Indian smartphone price of ₹12,000 / $160.

Source: statista.com/statistics/809…
Quick caveat: I’m not pretending that my internet experience has been identical to that of an average Indian smartphone-user

The average mobile internet speed in India is 12Mbps, roughly 1/3rd global average. But unless you’re video-streaming, 12Mbps seems OK to me?
Read 16 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

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

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!