Skip to content

Commit 9cbe840

Browse files
Blog: Automatic Class Sorting with Prettier - Fix examples (#2019)
**Blog page:** [Automatic Class Sorting with Prettier](https://tailwindcss.com/blog/automatic-class-sorting-with-prettier) **Problem:** The "before" and "after" code snippets in the blog post are identical. It seems the Prettier plugin unintentionally formatted the "before" snippet as well. 😉 Issue: #2020 **Fixes:** - Updated the "before" code snippets to reflect the intended unformatted state. --------- Co-authored-by: Philipp Spiess <[email protected]>
1 parent f0eb3d6 commit 9cbe840

File tree

1 file changed

+7
-6
lines changed
  • src/blog/automatic-class-sorting-with-prettier

1 file changed

+7
-6
lines changed

src/blog/automatic-class-sorting-with-prettier/index.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ People have been talking about the best way to sort your utility classes in Tail
3030

3131
This plugin scans your templates for class attributes containing Tailwind CSS classes, and then sorts those classes automatically following our [recommended class order](#how-classes-are-sorted).
3232

33+
{/* prettier-ignore */}
3334
```html {{ filename: 'HTML' }}
3435
<!-- Before -->
35-
<button class="bg-sky-700 px-4 py-2 text-white hover:bg-sky-800 sm:px-8 sm:py-3">...</button>
36+
<button class="text-white px-4 sm:px-8 py-2 sm:py-3 bg-sky-700 hover:bg-sky-800">...</button>
3637

3738
<!-- After -->
3839
<button class="bg-sky-700 px-4 py-2 text-white hover:bg-sky-800 sm:px-8 sm:py-3">...</button>
@@ -75,7 +76,7 @@ Utilities themselves are sorted in the same order we sort them in the CSS as wel
7576

7677
{/* prettier-ignore */}
7778
```html
78-
<div class="p-4 pt-2"> <!-- [!code --] -->
79+
<div class="pt-2 p-4"> <!-- [!code --] -->
7980
<div class="p-4 pt-2"> <!-- [!code ++] -->
8081
<!-- ... -->
8182
</div>
@@ -86,7 +87,7 @@ The actual order of the different utilities is loosely based on the box model, a
8687

8788
{/* prettier-ignore */}
8889
```html
89-
<div class="ml-4 flex h-24 border-2 border-gray-300 p-3 text-gray-700 shadow-md"> <!-- [!code --] -->
90+
<div class="text-gray-700 shadow-md p-3 border-gray-300 ml-4 h-24 flex border-2"> <!-- [!code --] -->
9091
<div class="ml-4 flex h-24 border-2 border-gray-300 p-3 text-gray-700 shadow-md"> <!-- [!code ++] -->
9192
<!-- ... -->
9293
</div>
@@ -97,7 +98,7 @@ Modifiers like `hover:` and `focus:` are grouped together and sorted after any p
9798

9899
{/* prettier-ignore */}
99100
```html
100-
<div class="scale-125 opacity-50 hover:scale-150 hover:opacity-75"> <!-- [!code --] -->
101+
<div class="hover:opacity-75 opacity-50 hover:scale-150 scale-125"> <!-- [!code --] -->
101102
<div class="scale-125 opacity-50 hover:scale-150 hover:opacity-75"> <!-- [!code ++] -->
102103
<!-- ... -->
103104
</div>
@@ -108,7 +109,7 @@ Responsive modifiers like `md:` and `lg:` are grouped together at the end in the
108109

109110
{/* prettier-ignore */}
110111
```html
111-
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4"> <!-- [!code --] -->
112+
<div class="lg:grid-cols-4 grid sm:grid-cols-3 grid-cols-2"> <!-- [!code --] -->
112113
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4"> <!-- [!code ++] -->
113114
<!-- ... -->
114115
</div>
@@ -119,7 +120,7 @@ Any custom classes that don't come from Tailwind plugins (like classes for targe
119120

120121
{/* prettier-ignore */}
121122
```html
122-
<div class="select2-dropdown p-3 shadow-xl"> <!-- [!code --] -->
123+
<div class="p-3 shadow-xl select2-dropdown"> <!-- [!code --] -->
123124
<div class="select2-dropdown p-3 shadow-xl"> <!-- [!code ++] -->
124125
<!-- ... -->
125126
</div>

0 commit comments

Comments
 (0)