最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

visual studio code - Tailwind CSS v4 - Unknown at rule @plugin, @custom-variant, @theme in global.css - Stack Overflow

programmeradmin2浏览0评论

I'm using Tailwind CSS v4 in my Next.js project and getting the following errors in globals.css:

Unknown at rule @plugin css(unknownAtRules)
Unknown at rule @custom-variant css(unknownAtRules)
Unknown at rule @theme css(unknownAtRules)

also @apply.

Here is my globals.css file:

@import "tailwindcss";

@plugin "tailwindcss-animate";

@custom-variant dark (&:is(.dark *));

@theme inline {
  /* theme customization */
}

I'm using Tailwind CSS v4 in my Next.js project and getting the following errors in globals.css:

Unknown at rule @plugin css(unknownAtRules)
Unknown at rule @custom-variant css(unknownAtRules)
Unknown at rule @theme css(unknownAtRules)

also @apply.

Here is my globals.css file:

@import "tailwindcss";

@plugin "tailwindcss-animate";

@custom-variant dark (&:is(.dark *));

@theme inline {
  /* theme customization */
}

Share Improve this question edited Apr 8 at 7:59 rozsazoltan 11.2k6 gold badges20 silver badges59 bronze badges asked Mar 16 at 18:16 Moazzam SonuMoazzam Sonu 293 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

These are custom TailwindCSS directives that CSS IDEs don't understand by default. For VSCode, use the official TailwindCSS IntelliSense extension.

  • TailwindCSS IntelliSense - VSCode Marketplace

After that, tell VSCode that you want to treat your .css files as TailwindCSS. You can do this in the settings under files.associations like this:

{
  "files.associations": {
    "*.css": "tailwindcss",
    "*.scss": "tailwindcss",
  },
}
  • Recommended VSCode settings for TailwindCSS IntelliSense - GitHub

Since these are just IDE error messages, the code will work as expected if you have properly installed TailwindCSS. However, they can be frustrating, so it is definitely recommended to use the extension.

Known Issues

  • Auto-completion and suggestions not working with TailwindCSS v4 - StackOverflow

It may happen that the syntax highlighting for the mentioned syntax will not work properly with the solution, this is a known issue:

  • tailwindlabs/tailwindcss-intellisense issue #1250 - GitHub

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论