A Visual Studio Code extension that provides intelligent autocompletion for CSS classes in PostCSS files. Get instant class suggestions while working with CSS, HTML, JSX, and TSX files.
- 🚀 Intelligent autocompletion for CSS classes
- ✨ Works across multiple file types:
- CSS files (for
composes: from global
) - HTML files (for
class
attributes) - JSX/TSX files (for
className
props) - JavaScript files with JSX
- CSS files (for
- 🔎 Hover information for CSS classes in:
- CSS
composes: from global
statements - HTML
class
attributes - JSX/TSX
className
props
- CSS
- 🔧 Configurable CSS path - use any CSS file in your project
- 🎯 Context-aware suggestions
- 🎨 Automatic spacing between multiple classes
- 🔍 Class Explorer panel with search functionality
- 💨 Loading indicators for better user experience
- 🔄 Framework-agnostic - works with any PostCSS project
- Open VS Code
- Press
Cmd+P
(macOS) orCtrl+P
(Windows/Linux) - Type
ext install smallcase.postcssense
- Press Enter
- Open the Command Palette (
Cmd+Shift+P
/Ctrl+Shift+P
) - Type "PostCSSense: Set CSS Path"
- Enter the path to your main CSS file (relative to workspace root)
- Example:
src/styles/main.css
- Example:
The extension provides intelligent features in various file types:
.your-class {
composes: /* Suggestions appear here */ from global;
}
<div className="/* Suggestions appear here */" />;
{
/* Template literals are supported */
}
<div className={`base-class ${isActive ? 'active' : ''}`} />;
{
/* Conditional classes work too */
}
<div className={`${condition ? 'conditional-class' : ''} always-present`} />;
<div class="/* Suggestions appear here */"></div>
const element = <div className="/* Suggestions appear here */" />;
Hover over class names to see their CSS properties:
.your-class {
composes: button-primary from global; /* Hover over button-primary */
}
<div className="button-primary layout-flex" /> {/* Hover over class names */}
<div class="button-primary layout-flex"></div>
<!-- Hover over class names -->
- Open the Command Palette (
Cmd+Shift+P
/Ctrl+Shift+P
) - Type "PostCSSense: Show CSS Classes"
- A panel will open showing all CSS classes with their properties
- Use the search box to filter classes by name
You can configure the extension through VS Code settings:
- Open Settings (
Cmd+,
/Ctrl+,
) - Search for "PostCSSense"
- Update the "CSS Path" setting with your preferred path
Alternatively, add this to your settings.json
:
{
"postcssense.cssPath": "path/to/your/css/file.css"
}
The extension automatically handles various import formats in your CSS files:
-
Package imports (from
node_modules
):@import '@package-name/style.css'; @import '~package-name/style.css';
-
Relative imports (relative to the current file):
@import './components/button.css'; @import '../styles/variables.css';
The extension supports various syntaxes for global CSS classes:
-
Standard CSS classes:
.button-primary { ...; }
-
Global function syntax:
.global(button-primary) { ...; } global(.button-primary) { ...; }
-
CSS Modules :global syntax:
:global .button-primary { ...; } :global(.button-primary) { ...; }
All these formats are properly recognized for autocompletion and hover information.
- Visual Studio Code version 1.77.0 or higher
- PostCSS based CSS files in your project
If you find any issues, please report them here.
Contributions are welcome! Feel free to:
- Fork the repository
- Create a feature branch
- Submit a pull request
This extension is licensed under the MIT License. See the LICENSE file for details.