Automatically organize Tailwind CSS classes into semantic groups with inline category comments. Works in ESLint, Prettier, and this live playground.
npm install --save-dev eslint-plugin-tailwind-group
.eslintrc:
{
"plugins": ["tailwind-group"],
"rules": {
"tailwind-group/group-tailwind-classes": [
"warn",
{
"formatInline": false,
"useClsx": true
}
]
}
}
npm install --save-dev prettier-plugin-tailwind-group
prettier.config.js:
module.exports = {
plugins: ['prettier-plugin-tailwind-group'],
tailwindGroup: true,
tailwindGroupMinClasses: 4,
tailwindGroupIncludeComments: true // set false to omit inline category comments
};
Requires Prettier v3 and assumes clsx (or equivalent) is available.
Size – text sizes, w/h, min/max
Layout – flex/grid, position, justify/items
Spacing – margin, padding, space-*
Border – border, ring, outline, rounded
Background – bg-*, gradient, backdrop-*
Text – font, text-*, placeholder-*
Effects – shadow, opacity, transition/animate
States & Variants – hover/focus/dark/responsive
Responsive – sm/md/lg/xl/2xl
Others – unmatched utilities