Sorting Tailwind CSS Classes Automatically with Prettier

Sorting Tailwind CSS Classes Automatically with Prettier

Tailwind Labs

2 года назад

85,821 Просмотров

In this video, I'll show you how to set up Prettier and the new Prettier plugin for Tailwind CSS, which will sort your classes automatically. One thing less to argue about with your team!

00:00 – Introduction
00:32 – Setting up Prettier
02:47 – Formatting on save
03:40 – Installing the Prettier plugin for Tailwind CSS
04:41 – How classes are sorted
05:57 – High impact classes first
06:46 – Modifiers grouped together
07:16 – Sorting custom classes
07:59 – Formatting an existing project
09:40 – Outro
Ссылки и html тэги не поддерживаются


Комментарии:

@bassman2145
@bassman2145 - 13.10.2023 19:33

Does anyone know what font is being used in the code editor?

Ответить
@chrisdedavid1860
@chrisdedavid1860 - 07.10.2023 20:29

Not sure why that plugin didn't work for me, I could get this to work only by using a different prettier plugin "prettier-plugin-tailwind-css"

Ответить
@waleedreaper413
@waleedreaper413 - 29.09.2023 08:28

Hi, this prettier plugin is not working in my project. I'm trying to use it in a Vite React app. Is there a different setup for it? Could someone please solve this problem. Prettier itself is working fine but this plugin for tailwind css is not.

Ответить
@zain.sadaqat
@zain.sadaqat - 17.09.2023 14:05

It's not working for me

Ответить
@lambo-ca
@lambo-ca - 01.09.2023 10:49

Sorting for did not work.

Ответить
@kamilksen
@kamilksen - 30.08.2023 19:16

Sad that it has peer dependency broken in Node 20 and newest version of prettier :/

Ответить
@bestchoice7431
@bestchoice7431 - 05.08.2023 15:37

Your prettier-plugin-tailwindcss does not work with vs code. Can you please give any quick solution for this?

Ответить
@FONO63
@FONO63 - 03.08.2023 07:19

This plugin is not working properly on the current version of VS and prettier. Had to switch to Headwind instead.

Ответить
@Kwuasimoto
@Kwuasimoto - 02.08.2023 04:03

Wow.. I've been using tailwindcss for almost 2 years now and this is the first I've seen this plugin, absolute game changer.

Ответить
@alexander.kachkaev
@alexander.kachkaev - 14.07.2023 16:44

👋 folks! One of Prettier maintainers here. Note that starting with Prettier v3.0, plugin autoloading is no longer available. After installing `prettier-plugin-tailwindcss`, it is necessary to specify it in the config file (prettier.config.js, .prettierrc.json., etc.).

{
"plugins": ["prettier-plugin-tailwindcss"]
}

Ответить
@nikhil182
@nikhil182 - 07.07.2023 14:27

Oh god, did I just see a Shiba at first?😍😍

Ответить
@psyferinc.3573
@psyferinc.3573 - 13.06.2023 10:01

i learn so much from any of your videos. thank you .

Ответить
@cyimanafaisal6800
@cyimanafaisal6800 - 03.06.2023 20:54

what if I am using react or nextjs

Ответить
@Antebios
@Antebios - 18.04.2023 04:39

This is such a time saver. I can't believe I wasted so much time spacing manually.

Ответить
@oussamasethoum1665
@oussamasethoum1665 - 31.03.2023 18:30

this plugin never worked for me

Ответить
@Adrian-ol1uz
@Adrian-ol1uz - 22.03.2023 14:21

How to change font for "class", "html", "lang" and other html props?

Ответить
@michaelsaucedo3952
@michaelsaucedo3952 - 15.03.2023 00:18

What about getting rid of extra spaces between class names?
className=" mx-auto my-auto text-white "

Ответить
@kemoboy
@kemoboy - 24.02.2023 00:29

I love tailwind. Tho, I'm facing a problem... I'm switching gears from JS to WordPress for a contract work and I can't, for the sake of sanity make the "Automatic class sorting" work with any .php file. It works with .html but not with .php. Does anyone know a solution to this problem? I'm using VSCode.

Ответить
@faizalhaziqahmadyani6066
@faizalhaziqahmadyani6066 - 15.02.2023 05:34

hi, how do i set this up on my wordpress project?

Ответить
@nivethan_me
@nivethan_me - 14.02.2023 04:55

i saw a lot of comments about @apply BUT you shouldn't use @apply, in future it will throw a build error

Ответить
@RichReflectionz
@RichReflectionz - 11.02.2023 19:05

This has been very helpful as I like things structured and easier to follow. Thanks for this extension to help with sorting.

Ответить
@devsbuddy
@devsbuddy - 06.02.2023 08:23

As i am mostly working with laravel framework which uses blade and prettier is throwing error that it
can not format the blade files.

Ответить
@chronosceptor
@chronosceptor - 28.01.2023 18:52

Why didn't I see this video before? thanks

Ответить
@maideakd9808
@maideakd9808 - 19.01.2023 18:15

Why doesnt this work on my .php files, or on ad wordpress project ? Prettier works fine but it doesnt sort any classes

Ответить
@Ibrahim-fh6kv
@Ibrahim-fh6kv - 18.01.2023 06:27

Is there a way to break the long Tailwind CSS class into multiple lines, in order to make it readable?

Ответить
@oussamasethoum2755
@oussamasethoum2755 - 01.12.2022 03:17

I can't get the extension to format the classes in solidjs

Ответить
@jjrise
@jjrise - 04.10.2022 05:52

man these videos are pure gold... thank you so much

Ответить
@samuelerbo
@samuelerbo - 27.09.2022 21:02

Great video. Thanks!!

Ответить
@dylanroberts9351
@dylanroberts9351 - 27.09.2022 05:36

How do you get an emoji to appear on your terminal?

Ответить
@EvgenyBobkin
@EvgenyBobkin - 28.08.2022 20:33

Thank you for this info, however, I had hard time with getting this plugin working with pnpm.

Ответить
@backupmemories897
@backupmemories897 - 27.08.2022 10:32

dint work on me

Ответить
@Hristovaa
@Hristovaa - 26.06.2022 15:04

Workaround for blade - Blade formatter has a tailwind class sorting option and I still use prettier for the css files to sort the classes with @apply. Anyone has a better solution?

Ответить
@miyanhassanaraien5607
@miyanhassanaraien5607 - 15.06.2022 00:35

Thank You!

Ответить
@proteus1
@proteus1 - 28.04.2022 14:28

Imposible to install this. I just can't get it to work even though I didi a step by step install with Visual Studio.

Ответить
@Aj-po9dc
@Aj-po9dc - 18.04.2022 01:43

This is terrible. I like the idea of auto sorting tailwind classes... but there should be a way to change the way it sorts them...

I mean really... There should be only 2 ways to sort them in my mind.

1) The way that it does, by mimicking the compiled file.
OR... and the way I would prefer, personally...
2) Keep the style sorted together. ex: all flex related classes stay grouped together, all grid related classes stay grouped together, all colors stay grouped together.... etc etc... And the reason why I would like this way is that I wouldn't have to read through all the classes to find the specific class that I have forgotten to add, because it isn't in the flex section...

Anyways... that's my two cents and am disappointed that I don't even get an option to rewrite the sort order...

But.. I do LOVE tailwind and every other CSS tool should be buried... LoL

Ответить
@ThomasBurleson
@ThomasBurleson - 17.04.2022 23:06

This video is wonderful and provides interesting insights:
Changing the Tailwind directive order in you class="..." does not affect the generated CSS in any way. The specific ordering is enforced during compile/generation. This is an important fact to have when talking about adoption of Tailwind CSS!

Ответить
@mrsan385
@mrsan385 - 13.04.2022 16:18

What's the name of the theme that you are using???

Ответить
@Buffalo_Debile
@Buffalo_Debile - 20.03.2022 21:37

How can I make that work with tailwind CDN ?

Ответить
@aislanarislou
@aislanarislou - 20.03.2022 08:08

How to make prettier break lines for each group of tailwind classes?

Ответить
@chichebem
@chichebem - 11.03.2022 16:37

Amazing!!! I started using tailwindcss 4 months ago and it has been AMAZING 🗣

Ответить
@tigerhex
@tigerhex - 02.03.2022 11:17

someone tell me what font he's using in vscode....?

Ответить
@axedyson
@axedyson - 26.02.2022 11:14

eslint-plugin-tailwindcss is pretty good too!

Ответить
@Mikkysam52
@Mikkysam52 - 24.02.2022 16:46

doesn't Headwind vscode extension do that?

Ответить
@ivantorres2494
@ivantorres2494 - 16.02.2022 12:11

could someone tell me if this works with attributify classes?

Ответить
@misaka5368
@misaka5368 - 16.02.2022 06:37

I learned css from tailwind best ever tools love u

Ответить
@hernanmartinezreumann3279
@hernanmartinezreumann3279 - 15.02.2022 01:45

Does this work only for Tailwind V3? I can't make it work in my Laravel project with Tailwind 2

Ответить