Tailwind CSS defines itself on its official site as:
A utility-first CSS framework packed with classes.
In this post I'll explain to you what d...
For further actions, you may consider blocking this person and/or reporting abuse
Thank you for your excellent article 👍. I stopped using it at some point due to the poor code readability. In reality, in large projects, it often looks like this:
<a class="rounded-md bg-indigo-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"></a>There's a good reason why solutions like this now exist, offering readable classes for use: daisyui.com
I agree that it becomes a bit cluttered looking as a big long string, but I stopped inlining classnames in JSX a while back and it pretty much resolved the problem. My usual component structure is something like:
so that the component file is something like:
and the utils file has:
This is exactly what PandaCSS already does.
I think it's a pretty common pattern. I made a package (tailwind-classlist) back in 2018ish that did something similar, although it's no longer maintained. Handled merging conflicting classes and everything as well.
Nice!
NYC bro
I like to use tw fare better than using any other CSS solution because the layout related solution so simple like
grid gap-2for vertical list. Also can solve dark/light skin change and responsive design at zero cost.Tailwind likes to pretend it's the only option with those benefits, but that's not really (really not) true. PandaCSS for example has the same benefits, but none of the downsides of having to learn a new utility class language.