Skip to content

Classes with custom variable names are not sorted #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sboerrigter opened this issue Apr 9, 2025 · 3 comments
Open

Classes with custom variable names are not sorted #357

sboerrigter opened this issue Apr 9, 2025 · 3 comments

Comments

@sboerrigter
Copy link

What version of prettier-plugin-tailwindcss are you using?

0.6.11

What version of Tailwind CSS are you using?

4.1.3

What version of Node.js are you using?

v23.6.1

What package manager are you using?

npm

What operating system are you using?

macOS

Reproduction URL

https://play.tailwindcss.com/DPP55XQUZZ

Describe your issue

Tailwind with custom variable names are not sorted correctly. For example, if the following color variable is defined:

@theme {
  --color-primary-600: var(--color-blue-600);
}

Classes containing -primary-600 are moved to the front of the list. So this:

m-10 text-4xl font-extrabold text-gray-800 hover:text-primary-600

Becomes this:

hover:text-primary-600 m-10 text-4xl font-extrabold text-gray-800

See the example above. I am not sure why the "Tidy" button isn't working there, but if I format this locally, this issue occurs.

@sboerrigter sboerrigter changed the title Classes with custom variable names are not sorted correctly Classes with custom variable names are not sorted Apr 9, 2025
@spicrd
Copy link

spicrd commented Apr 21, 2025

Hello @sboerrigter,
I had the same issue. Turns out that with Tailwind CSS v4, you need to add this option to your Prettier config so that Prettier knows where to find your Tailwind configuration stylesheet:

// .prettierrc
{
  "tailwindStylesheet": "./resources/css/app.css"
}

You can find more about this in the documentation.

Hope this helps! 😊

@vafanassieff
Copy link

I have the same issue with a pnpm monorepo.

@isRyanSu
Copy link

Hello @sboerrigter, I had the same issue. Turns out that with Tailwind CSS v4, you need to add this option to your Prettier config so that Prettier knows where to find your Tailwind configuration stylesheet:

// .prettierrc
{
  "tailwindStylesheet": "./resources/css/app.css"
}

You can find more about this in the documentation.

Hope this helps! 😊

It works! Thank you. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants