Re:Tailwind CSS v3.0
by yasserkaddour on Thursday December 09, 2021 @07:59PM
(#29505217)
I love Tailwind! It elegantly solves most pain points in writing CSS. However, it does this at the cost of readability, and you can easily end up with HTML that looks like this:
I would love to have a transpiler that produces the line above from a code like this:
[ Parent
| on HN ]
https://windicss.org/ does it
It also seems that the major speed improvement in Tailwind is inspired by windi
Re:Tailwind CSS v3.0
by yasserkaddour on Thursday December 09, 2021 @08:16PM
(#29505329)
I looked into windicss before and didn't see the attributify mode https://windicss.org/features/attributify.html
It's exactly what I was looking for, Thanks!
Oh wow, that's pretty handy. I hadn't seen that before, either.
What about a helper function for that? Something like this:
const md = styles => styles.split(' ').map(style => 'md:' + style).join(' ')
Then const styles = [
'w-16 h-16 px-2 py-1 m-1 text-sm text-white bg-black rounded',
md('w-32 h-32 rounded-md text-base hover:rounded-xl')
].join(' ');
Then <div className={styles}>Hello</div>
I haven't actually tried this approach but it might clean some things up.Even spread out in attributes it’s hard to read
Re:Tailwind CSS v3.0
by happytiger on Thursday December 09, 2021 @08:24PM
(#29505372)
I moved to tailwind a month ago and it’s become incredibly easy to read and work with very quickly. It’s one of those frameworks that just clicks when people start using it, though I think a lot of people don’t feel that way until they put the time in to get familiar.
Re:Tailwind CSS v3.0
by yasserkaddour on Thursday December 09, 2021 @08:32PM
(#29505432)
Exactly!
My example fit a just seven lines colocated with your HTML, in CSS you would need to read a full page in a different file.