,

I Wish I Had Known These Tailwind Tips Sooner

Posted by

I WISH I Knew These Tailwind Tips Earlier

I WISH I Knew These Tailwind Tips Earlier

If you’re a web developer or designer, chances are you’ve heard of Tailwind CSS. It’s a utility-first CSS framework that has gained a lot of popularity in recent years. Whether you’re a beginner or an experienced user, there are always tips and tricks that can make your workflow more efficient. Here are a few Tailwind tips that I wish I knew earlier:

  1. Use the @apply directive: Tailwind makes it easy to create custom utilities, but the @apply directive allows you to group multiple utilities into a single class. This can clean up your HTML and make your styles more reusable.
  2. Understand the utility classes: Tailwind provides a large set of utility classes for styling elements. Understanding these classes and how they work together can save you time and make your code more consistent.
  3. Customize your configuration: Tailwind allows you to customize the default configuration to fit your project’s specific needs. Take the time to familiarize yourself with the configuration file and make adjustments as necessary.
  4. Use the @screen directive: Tailwind’s responsive design features are powerful, and the @screen directive allows you to create custom responsive classes based on screen sizes. This can make your design more flexible and adaptable to different devices.
  5. Explore the plugin ecosystem: Tailwind has a thriving plugin ecosystem that can extend its functionality. Whether you need additional components, design tools, or integrations with other libraries, there’s likely a plugin that can help you achieve your goals.

These are just a few of the tips that can help you make the most of Tailwind CSS. Whether you’re just getting started or you’ve been using it for a while, there’s always more to learn. By taking the time to explore the framework and its features, you can become a more efficient and effective developer or designer.

0 0 votes
Article Rating
20 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@Mempler
7 months ago

weirdly enough, tailwind felt actually really natural for me.

thus it wasnt scary at all!

@naveedalirehmani4135
7 months ago

what is the extension called? for tailwind class sorting.

@mohammednasser2159
7 months ago

Hi theo,
In svelte you can use
class:<className>={<varName>}
As an attribute to an element/component

This mixed with the @apply can provide good results that does not hurt the readability or locality of the code, since svelte has a per component styles
Which is a good pattern, what do you think ?

@UP209D
7 months ago

The whole purpose of tailwind is avoiding naming things

@troytempest3023
7 months ago

Epic Video! Love It!

@andreibicu5592
7 months ago

Hi
First of all, I love Tailwind and I use it on all of my projects.
I have a question for #3:
– What technical issues are you talking about?
If you're talking about the naming conventions, then there are standards for this (check BEM).
Everyone should be aware that using only tailwind classes you are limited with what tailwind has implemented from CSS. But CSS has so many options and I personally wouldn't recommend to anyone to only use classes in HTML, as it makes the code so much cluttered and harder to read and maintain. Not to mention it doesn't comply with the SRP.
On the other side, using a separate CSS file, you have full control to all the properties and can choose to use either Tailwind with @apply, either some custom styles or animations. Not to mention the reload performance is better as only CSS is changed.
Also, I don't think the costs of supporting @apply is our concern nor should be a decisive factor in how we write code. The tools we use should only improve our productivity.

@Pareshbpatel
7 months ago

{2023-10-19}

@robertostringa9254
7 months ago

It is so simply to debug css with dev tools. It is much more complex to understand the lines of code that tailwind generates.

@MoneyAlfons
7 months ago

we should not see tailwind as copy/pasting as we are actually "reusing" the defined classes, we should look at it more like at modular CSS

@iancarr3923
7 months ago

Excellent. Well delivered to camera. Glad you went crazy with Helen.

@portalpacific4500
7 months ago

Hot takes:

1) Chat gpt is better than cheat sheets now imo

2) Instead of re-using styles just use css variables. Define it as whatever u want. Change it in one place.

@moses5407
7 months ago

How do you use Prettier with Tailwind? TW newbie here

@badasspuppy
7 months ago

That prettier tip was awesome. Can't wait to play with it

@momolojo
7 months ago

I use the @apply directive to specifically make global styles, say text-style classes that to match a design system, `.ts–h1` or form input resets–there are not all that many things that make the cut.

@tiagoc9754
7 months ago

I was looking for some content about tailwind typography and found your video. You haven't mentioned it directly but I assume it's related to the tailwind config you mentioned in the very end. Do you have more videos or would mind sharing your thoughts about it? I'm pretty newbie in tailwind and saw a project with tons of changes on tailwind typography and it felt so weird to me that I don't know if that's really "correct" or if it's just me who isn't used enough to tailwind world. Thanks

@RaphFillion
7 months ago

I don't understand your take on @apply directive. We use WordPress (php and tailwind) to make websites, and we include a base styling to use on every website (like distance between different sections, text sizing, etc.). So for not repeating everything on every project, we have created a base css file with @apply directives with custom name classes which we can now use in our documents. It's also perfect for using with Gravity form styling and/or wysiwyg editor styling (we use prose in that case). So, I mean, there's the use for it, but I can see why you would want to avoid it in a one time deal project.

@iamvalenci4
7 months ago

okay but what about save the style for a input in a variable and then called that variable in the input field to style it? is a problem of performance this approach? I am student.

@howardgil499
7 months ago

I don't have Prettier plugin for Tailwind but Prettier seems to update the order on its own. Guess that was integrated after this video?

@doesitmatter
7 months ago

1:50 just write proper code and you will have to fix 1 place instead of all 5 links

@anhdunghisinh
7 months ago

Strange thing is, i had never used TW cheat sheet until i'm already very comfortable with the library, all i need was tailwind intellisense