Warning: semi-colon expectedcss
However, it doesn't work, and I am getting the following error:
semi-colon expectedcss(css-semicolonexpected)
I don't know the exact origin of the error message, but I assume it's a VSCode warning. It's likely caused by the prefix(tw) you added after the import, which is an unexpected CSS (but not TailwindCSS) syntax.
You should use the official TailwindCSS extension. Installation and some extra configuration (files.associations) are required, so please follow the next answer:
Prefix
I want to add the tw- prefix to all Tailwind CSS classes.
Starting from TailwindCSS v4, class names are no longer extended; instead, the prefix appears as a main utility. It must be applied before everything else. The goal is to make it easier to distinguish TailwindCSS class names from custom class names when reading the code.
From TailwindCSS v4 onwards
If you use a prefix, the following is valid. The prefix should be connected with a colon (:) rather than a hyphen (-). Additionally, the prefix should always be used as the first utility. By default, this would be tw:content, but due to other utilities, you need to gradually place the appropriate utilities in between.
@import "tailwindcss" prefix(myprefix);
myprefix:text-red-500
myprefix:hover:text-red-500
Until TailwindCSS v3
Until v3, prefixes had to be specified in the legacy JavaScript-based configuration. They did not function as utilities but were prepended to the original class name, independent of other utilities.
/** @type {import('tailwindcss').Config} */
export default {
prefix: 'myprefix-',
}
myprefix-text-red-500
hover:myprefix-text-red-500
tw-prefix; prefixes are now separated by:so it would betw:<classname>.