Skip to content

Conversation

@thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Oct 6, 2025

This feature, when used with a new enough Tailwind CSS version (v4.1.15+), allows IntelliSense to detect when a utility you've written could be written in a more succinct / optimal fashion. These suggestions are unique to your project so if you customize your theme that will be taken into account.

It can suggest utilities that match arbitrary ones:
Screenshot 2025-10-07 at 10 41 01

It can also match arbitrary values against values in your theme:
Screenshot 2025-10-07 at 10 41 45

This includes matching against custom theme values in your project:
Screenshot 2025-10-07 at 10 43 01

It even works for variants:
Screenshot 2025-10-07 at 10 44 07

And of course it works for both simultaneously:
Screenshot 2025-10-07 at 10 44 27

When presented with one of these diagnostics it will also have an accompanying code action that lets you replace the class:

Screenshot 2025-10-07 at 10 45 40

Note: Matching is done with mostly exact values to your theme so colors that parse to the same value but don't match won't necessarily be suggested. This is a possible future improvement but requires some design work in Tailwind CSS itself.

@thecrypticace thecrypticace force-pushed the feat/canonical-diagnostic branch from 0866277 to 288d027 Compare October 7, 2025 11:08
@thecrypticace thecrypticace force-pushed the feat/canonical-diagnostic branch from 288d027 to 310167e Compare October 7, 2025 14:17
@thecrypticace thecrypticace marked this pull request as ready for review October 7, 2025 14:47
@thecrypticace thecrypticace merged commit f922ed0 into main Oct 7, 2025
12 checks passed
@thecrypticace thecrypticace deleted the feat/canonical-diagnostic branch October 7, 2025 15:08
@pondorasti
Copy link

are there any plans for a codemod to autofix canonical warns?

we have a large monorepo with upwards of hundreds of files that could be automatically cleaned up with the help of a codemod

@thecrypticace
Copy link
Contributor Author

The upgrade tool does this already — you can re-run it against your v4 codebase:

npx @tailwindcss/upgrade

@pondorasti
Copy link

thanks, this worked great! 🤗

maybe worth separate issue, but it would be nice to have this as part of the prettier plugin and be able to autofix canonical warns outside the codemod

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

Successfully merging this pull request may close these issues.

4 participants