[Prettier Plugin] Tailwind string variables sorting #13045
Closed
ChiuMungZitAlexander
started this conversation in
Ideas
Replies: 1 comment
-
The Tailwind Prettier plugin needs hints to recognize Tailwind CSS classes for formatting. It automatically parses common class declaration attributes like To help Prettier recognize the string, you can use Template Literals. Refer to the documentation for setting up your environment correctly: Sorting classes in template literals. // prettier.config.js
module.exports = {
tailwindFunctions: ['tw'],
}
// in your code
const tw = (strings, ...values) => String.raw({ raw: strings }, ...values)
const mySortedClasses = tw`bg-white p-4 dark:bg-black` |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I know Prettier Plugin will sort tw classnames in jsx elements.
But if I have a classname string:
it will ignore sort.
I am not sure if it is a good practice to sort the string like above.
Beta Was this translation helpful? Give feedback.
All reactions