DEV Community

Cover image for Life Pro Tips for TailwindCSS Projects

Life Pro Tips for TailwindCSS Projects

Wade Zimmerman on December 19, 2021

Recently, TailwindCSS released version 3.0 and the framework remains highly popular. Do you know all the little tricks for cleaner code? ...
Collapse
 
lamka02sk profile image
lamka02sk

Aspect ratio is cool, but the browser support isn't. If you are okay with supporting the very few latest versions, then fine, but I would not recommend using it just yet.

Collapse
 
wadecodez profile image
Wade Zimmerman • Edited

You're right only ~79% of browsers support the CSS aspect-ratio property. Luckily, there is a Tailwind plugin for aspect ratios which uses the padding-bottom hack. This is when insets become handy.

Aspect ratio plugin

Can I use aspect-ratio?

Collapse
 
lamka02sk profile image
lamka02sk

Thank you, didn't know about the plugin. I will definitely try it

Thread Thread
 
pavelloz profile image
Paweł Kowalski

Yep, dont forget about that important IE 11 :D

Fun fact: Last month i installed windows with ie 8 and for an hour i didnt manage to either update it to newer version, nor install firefox/chrome. Its so old SSL certificates, broken layouts and network issues made that impossible. I wonder hows life in the ie 11 land nowadays.

Thread Thread
 
lamka02sk profile image
lamka02sk

It is not about IE11, it is any browser before 2021...

Thread Thread
 
pavelloz profile image
Paweł Kowalski

Why care about browsers, when we can care about people.

Collapse
 
virajsingh19 profile image
Viraj Singh

I think flex spacing is also a good technique to know. Instead of spacing the children with margin classes like mr-5, you could space them at once using space-x-5 in the flex parent

Collapse
 
pavelloz profile image
Paweł Kowalski

+1, flex is great :)
space-x-5 is great.
I found gap-x-5 classes also helpful.

Collapse
 
kevinast profile image
Kevin Bridges

Thanks for the tailwind tips!

A bit off topic, but you might be interested in tw-themes: which promotes color themes that are dynamically selectable at run-time, and automates your dark-mode through "shade inversion".

tw-themes.js.org/

At minimum, I would be interested in your thoughts :-)

Collapse
 
alexkarpen profile image
alexkarpen

Many thanks

Collapse
 
dualyticalchemy profile image
⚫️ nothingness negates itself

your examples are so milquetoast not about anything pragmatic nor practical, not about something at all

Collapse
 
wadecodez profile image
Wade Zimmerman

I agree! Perhaps a more suited expert should write a thorough step-by-step guide with real life examples. Surely a more tautological approach would win. My life is too DRY for such a task. The intellects must devote their time for these child developers. Computational systems including ML/AI are fundamentally flawed without philosophical or sociological backgrounds. Why are we wasting our time on styling websites for consumerism?

Collapse
 
dualyticalchemy profile image
⚫️ nothingness negates itself
Thread Thread
 
wadecodez profile image
Wade Zimmerman

Well played and well versed. I admit defeat.

Collapse
 
pawelmiczka profile image
Paweł Miczka

there are also space-[x/y]-* utility which is perfect to adding gaps to non grid layouts - highly recommend

Collapse
 
imiahazel profile image
Imia Hazel

Thanks for sharing the practical tips. Inset Positioning is engaging.

Collapse
 
dandoestech profile image
Dan D

Great article!

Collapse
 
emurrell profile image
Eric Murrell

Good article!