Skip to content

Syntax highlighting for Tailwind CSS v4 directives (@utility, @custom-variant, @variant) #1250

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
devenini opened this issue Mar 5, 2025 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@devenini
Copy link

devenini commented Mar 5, 2025

What version of VS Code are you using?

v1.98.0

What version of Tailwind CSS IntelliSense are you using?

v0.14.8

What version of Tailwind CSS are you using?

v4.0.9

What package manager are you using?

npm

What operating system are you using?

macOS

VS Code settings

{
    "tailwindCSS.experimental.configFile": "./src/styles/main.css",
    "files.associations": {
        "*.css": "tailwindcss"
    }
}

Describe your issue

Currently, when using Tailwind CSS v4 directives such as @utility, @custom-variant, or @variant, syntax highlighting is lost, and everything appears as plain white text. This makes it difficult to differentiate styles and maintain readability.

Image

Features like suggestions and hover work correctly.

Steps to reproduce:

  • Use any of the Tailwind CSS v4 directives in an editor with syntax highlighting.
  • Observe that the syntax coloring disappears.
@thecrypticace thecrypticace added the enhancement New feature or request label Mar 5, 2025
@thecrypticace thecrypticace self-assigned this Mar 5, 2025
@thecrypticace
Copy link
Contributor

This is something I have on my todo list. Might spend some time on it in the next week or two. I was really hoping that nested CSS syntax highlighting in VSCode's native CSS grammar would've shipped by now but it hasn't yet so need to handle this ourselves.

@haversnail
Copy link

haversnail commented Mar 18, 2025

FWIW, it seems that nesting your styles will trigger the correct syntax highlighting; for example:

@utility tab-* {
  & {
    tab-size: --value(--tab-size-*);
  }
}

In VS Code:
Image

Not ideal ofc, but helps keep me sane for the time being. 🙂

@callummr
Copy link

callummr commented Apr 15, 2025

Forgive the likely naiive take, I've just found this issue while wondering what's wrong with my @utility rules and have no knowledge of VS Code extensions. Just changing the utility body include from source.css#rule-list to source.css#rule-list-innards seems to fix the highlighting for me. Nesting is still broken, but having the expected syntax at the top level seems like a real and quick improvement while nesting is worked/waited on?

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

No branches or pull requests

4 participants