Tailwind CSS IntelliSense
Complete guide to the Tailwind CSS IntelliSense VS Code extension, autocomplete, hover preview of generated CSS, color decorators, and class validation.
What It Does
The Tailwind CSS IntelliSense extension (bradlc.vscode-tailwindcss) provides intelligent autocomplete, syntax highlighting, hover previews of generated CSS rules, and linting for Tailwind CSS classes across HTML, JSX, TSX, Vue, and CSS files.
Why Use It
- Autocomplete for Class Names: Suggests utility classes as you type with instant fuzzy matching.
- Hover Previews: Hovering over any class name (e.g.
bg-sky-500) reveals the exact underlying CSS properties (background-color: rgb(14 165 233);). - Color Decorators: Displays live color swatches in the editor gutter and inline next to color class names.
- Linting & Diagnostics: Highlights invalid utility class names, conflicts, and deprecated syntax.
Installation
- VS Code Marketplace: Search for
bradlc.vscode-tailwindcssand click Install. - CLI:
code --install-extension bradlc.vscode-tailwindcss
Configuration
In .vscode/settings.json:
{
// Enable autocomplete inside custom attributes or template literals
"tailwindCSS.experimental.classRegex": [
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
["cn\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"]
],
// Trigger suggestions on string quotes
"editor.quickSuggestions": {
"strings": "on"
},
// Highlight conflicting class names (e.g. p-2 and p-4 on same element)
"tailwindCSS.lint.conflicts": "warning"
}Use Cases & Examples
Autocomplete with cn() / clsx Utility
When using class merging libraries (shadcn/ui or Tailwind Merge):
import { cn } from "@/lib/utils";
export function Button({ className }: { className?: string }) {
return (
<button
className={cn(
"px-4 py-2 font-medium rounded-lg transition-colors", // Full autocomplete here
"bg-primary text-primary-foreground hover:bg-primary/90",
className
)}
/>
);
}Alternatives
- UnoCSS Language Server: High-performance engine for UnoCSS.
- Windi CSS IntelliSense: Legacy utility CSS extension.
Performance & Security Considerations
- Requires Tailwind Config: The extension activates automatically only when a
tailwind.config.js,tailwind.config.ts, or Tailwind v4@themeblock is detected in the workspace root. - Large Monorepos: Configure
"tailwindCSS.rootConfigFile": "apps/web/tailwind.config.js"if your config is located in a sub-package.
Related Guides
Error Lens: Inline Error & Warning Highlighting
Complete guide to the Error Lens VS Code extension, inline diagnostic messages, font customization, filtering noise, and boosting debugging speed.
Docker Extension for VS Code
Complete guide to the official Docker extension for VS Code, managing containers, images, volumes, networks, and Dockerfile autocomplete and linting.