Make Your Code More Readable
In modern web development, consistent code formatting is crucial. Tailwind CSS's utility classes can quickly become a tangled mess, making your code:
Hard to read
Difficult to maintain
Challenging for team collaboration
The Prettier Tailwind CSS plugin automatically sorts and organizes utility classes, bringing instant order to your code with minimal effort.
pnpm add -D prettier prettier-plugin-tailwindcss
Create a .prettierrc
configuration:
{
"plugins": ["prettier-plugin-tailwindcss"]
}
Now use your format document shortcut 💢
OR
echo '{
"plugins": ["prettier-plugin-tailwindcss"]
}' > .prettierrc
Alternatively, you can create the file directly via the terminal 😍
Instead of formatting a single file manually, format the entire codebase with Prettier using the following script:
In your package.json
, add these scripts:
"scripts": {
"format": "prettier --write .",
"format:check": "prettier --check ."
}
Then, run
pnpm format
🔍 Automatically sorts tailwind classes
🚀 Improves code readability
👥 Enhances team collaboration
⏱️ Saves time and mental energy
If you enjoyed this article or found it helpful, feel free to share it with others!
I'd love to hear your thoughts—connect with me on Github, Peerlist.
Join Jay on Peerlist!
Join amazing folks like Jay and thousands of other people in tech.
Create ProfileJoin with Jay’s personal invite link.
0
5
0