News for hackers. Stuff that matters.
Re:Goodbye CSS Modules, Hello TailwindCSS by donatj on Thursday November 04, 2021 @03:57PM (#29111810)
I've always been of the mind that if you like tailwind, you'll love the flexibility inline css gives you, and without the need for interim tools!
Re:Goodbye CSS Modules, Hello TailwindCSS by adamwathan on Thursday November 04, 2021 @04:05PM (#29111903)
The biggest issue with inline styles is you can't use media queries or pseudo-classes like hover, focus, etc, which effectively means you can't build anything of substance with them.

Agree that if inline styles offered all of the features you get when writing your CSS in a stylesheet that it would be a compelling option because of the simplicity, even though the verbosity would be a big knock against.

Re:Goodbye CSS Modules, Hello TailwindCSS by codyogden on Thursday November 04, 2021 @04:24PM (#29112132)
I know you're the creator of Tailwind. However, using emotion’s css() from @emotion/react feels like the best of both worlds. Essentially, writing inline styles but with the ability to do media queries, pseudo classes, and conditional styling based on state. I didn’t like CSS modules, I never quite “got” Tailwind’s functional take on CSS which left me feeling inflexible, but I found something great with emotion and it works wonderfully.
Re:Goodbye CSS Modules, Hello TailwindCSS by omnimus on Thursday November 04, 2021 @05:47PM (#29112911)
Might be best of both worlds if you write JS apps. Not if you write html :)
Re:Goodbye CSS Modules, Hello TailwindCSS by codyogden on Thursday November 04, 2021 @09:22PM (#29114445)
The context of this article is about managing CSS in a JavaScript application, so…
Re:Goodbye CSS Modules, Hello TailwindCSS by johnnypangs on Thursday November 04, 2021 @04:38PM (#29112289)
I had always heard inline styles were slower and not recommended by browsers. Here is a blog post looking into that:

https://simonadcock.com/are-inline-styles-faster-than-atomic...

In reality the difference wasn’t so big but inline styles might not scale well. (I also realize the original poster might have been sarcastic but it’s a fun to look into even the non serious ideas).

Re:Goodbye CSS Modules, Hello TailwindCSS by beebeepka on Thursday November 04, 2021 @07:10PM (#29113557)
Ha, truth is, inline styles are actually faster, not slower. The bigger your CSS files grow, the faster inline becomes.

I feel not enough people have experience with low power devices

Re:Goodbye CSS Modules, Hello TailwindCSS by elefantastisch on Thursday November 04, 2021 @04:40PM (#29112306)
Tailwind also offers curated (and curatable) styles instead of a free-for-all. You can set up Tailwind to exactly provide the levels of spacing, colors, fonts, etc. that you want for your design system. Tailwind is in some ways like inline CSS, but enhanced inline CSS that you can customize the options of precisely for your project/team/company. You don't have to use text-xs, text-sm, text-lg. You can use text-fineprint, text-prose, text-inyourface and configure them to be exactly the size you want. And then of course, you can change the definition of those styles in one place and have it propagate throughout your project. This is where Tailwind starts to move well beyond inline CSS.
Re:Goodbye CSS Modules, Hello TailwindCSS by teitoklien on Thursday November 04, 2021 @04:29PM (#29112184)
Um you can in tailwind

Its like

md:p-2 which is for m devices , make padding as 2 Or xl:p-4 , which is for xl devices , make padding as 4

Similarly for hover or focus in tailwind its

bg-white hover:bg-black focus:bg-red Which says , by default keep background of this element white , when you hover over it keep it black and when you focus on it , keep it red

Works just fine, Give it a try and go through the docs of tailwind, navigating it using algolia, is a joy :D

Re:Goodbye CSS Modules, Hello TailwindCSS by hanspagel on Thursday November 04, 2021 @04:37PM (#29112275)
I think Adam knows what’s possible with Tailwind CSS [1], but wanted to point out that it’s not possible with just a style attribute. :-)

[1] https://github.com/tailwindlabs/tailwindcss/graphs/contribut...

Re:Goodbye CSS Modules, Hello TailwindCSS by adamwathan on Thursday November 04, 2021 @06:03PM (#29113050)
Haha correct, I was just explaining why inline styles aren't a suitable alternative to Tailwind. Tailwind can definitely do all that stuff!
Re:Goodbye CSS Modules, Hello TailwindCSS by teitoklien on Friday November 05, 2021 @06:52AM (#29117541)
Thanks a lot for making tailwind ! Haha i didnt check the username before replying, sorry xD

Your project is the reason why i like building web interfaces again.

Re:Goodbye CSS Modules, Hello TailwindCSS by Kiro on Thursday November 04, 2021 @06:53PM (#29113437)
In case the other comment isn't clear: you're replying to the creator of Tailwind.
Re:Goodbye CSS Modules, Hello TailwindCSS by teitoklien on Friday November 05, 2021 @06:50AM (#29117526)
F Amen
Re:Goodbye CSS Modules, Hello TailwindCSS by Vanderson on Thursday November 04, 2021 @05:07PM (#29112537)
I found using inline CSS variables and clever use of selectors allows for both media queries and inline to work in harmony.
Re:Goodbye CSS Modules, Hello TailwindCSS by toomanydoubts on Thursday November 04, 2021 @04:13PM (#29111992)
Can we all finally agree then that this is not an issue with modern frontend technology which allows you to componentize your stuff? Yeah, it was bad when you had a hundred HTML files with repeated elements across them. Updating the style on one such element meant going through all these 100 files. Nowadays, if you want to change your button background color or your container width size, you should be able to change a single component and have that updated for your whole website. For me, that kinda fix the main issue people had when they started saying "do css, not inline styles".
Re:Goodbye CSS Modules, Hello TailwindCSS by rapind on Thursday November 04, 2021 @05:04PM (#29112514)
I think a big problem with CSS is the assumed best practice of starting with the abstraction / module (stylesheet) instead of starting inline and refactoring out like you’d do when coding in any other language.

It creates paralysis and feels like an upfront chore/ cost. Then naturally it’s hard to maintain because you didn’t know what the right abstraction was yet. You literally end up with everything modular (css files) even if it’s only used once.

I’m really enjoying elm-ui and the principles behind it.

Re:Goodbye CSS Modules, Hello TailwindCSS by sodapopcan on Thursday November 04, 2021 @05:09PM (#29112568)
This is exactly what I tell people when explaining why I like tailwind. It's very freeing. I mean, I tell them other good things too, but this one is big.
Re:Goodbye CSS Modules, Hello TailwindCSS by Vinnl on Thursday November 04, 2021 @06:08PM (#29113096)
Except you'd be missing out on Tailwind's constraints, which prevent someone like me (with not as much of an eye for design) from accidentally sneaking in little inconsistencies that make a design seem off.

(Like in another comment here, I'm rehashing a more extensive blog post [1] of mine here.)

[1] https://vincenttunru.com/why-tailwind/#constraints-set-you-f...

Re:Goodbye CSS Modules, Hello TailwindCSS by SavantIdiot on Thursday November 04, 2021 @05:46PM (#29112896)
Why do people prefer Tailwind to Bootstrap (css only)? THey both seem really similar but I've been using Bootstrap so long that I haven't had the impetus to change.
Re:Goodbye CSS Modules, Hello TailwindCSS by deergomoo on Thursday November 04, 2021 @07:23PM (#29113669)
Bootstrap and Tailwind are very different, though newer versions of Bootstrap do have more utility classes like Tailwind.

Bootstrap provides pre-made visual components, which are useful for getting stuff built quickly but can be a huge pain to tweak (e.g. you want 99% of the styles but just need the padding to be slightly different in one instance).

Tailwind provides no pre-made visual components, but instead provides a sensible design system to keep things consistent, and either a much more pleasant and scalable way to write CSS, or a horrible class soup, depending on your opinion of utility classes.

Re:Goodbye CSS Modules, Hello TailwindCSS by SavantIdiot on Thursday November 04, 2021 @10:39PM (#29114903)
Thanks, that's a really clear answer. Now it's got me scratching my head. I like not having to make a lot of decisions, hence my affinity toward BS. But TW might be worth a spin.
Re:Goodbye CSS Modules, Hello TailwindCSS by thomasfortes on Thursday November 04, 2021 @06:55PM (#29113457)
Bootstrap is a fully opinionated framework, tailwind is far more versatile, it has his opinions, but they aren't set in stone in the way that bootstrap is.

You can build bootstrap in tailwind, but you can't build tailwind with bootstrap.

Both are tools to help you design something, but the tradeoffs of each one are quite different.

Re:Goodbye CSS Modules, Hello TailwindCSS by SavantIdiot on Thursday November 04, 2021 @10:40PM (#29114907)
> You can build bootstrap in tailwind, but you can't build tailwind with bootstrap.

Well put.

Re:Goodbye CSS Modules, Hello TailwindCSS by grayrest on Thursday November 04, 2021 @04:02PM (#29111881)
The restrictions are a feature, not a bug.
Re:Goodbye CSS Modules, Hello TailwindCSS by CuriouslyC on Thursday November 04, 2021 @06:05PM (#29113072)
Inline css is very powerful, but tailwind gives you the vast majority of that power with a much smaller learning surface, and with the ability make sweeping style changes without having to update the css in every single component.
Re:Goodbye CSS Modules, Hello TailwindCSS by crisnoble on Thursday November 04, 2021 @04:13PM (#29111993)
Probably would actually be a valid way to go if you could do media queries and didn't need vendor prefixes.
Re:Goodbye CSS Modules, Hello TailwindCSS by 01brett on Thursday November 04, 2021 @05:12PM (#29112592)
Author here, most of the non-Tailwind CSS I write is browser-specific tweaks or hacks, and mostly for Safari.