Class Spy
Stop guessing what your CSS classes do — hover and see everything instantly.

What does it do?
Class Spy turns your class and className attributes into interactive CSS explorers. Hover over any class string in your code and instantly see:
- Where the CSS is defined — each custom class gets its own section with file name and full rule
- What Tailwind generates — all Tailwind utilities combined into one decoded CSS block
- SCSS
& nesting resolved — BEM suffixes (&__title), modifiers (&.active), and pseudo-classes (&:hover) are expanded to their real class names
- Unknown classes flagged — classes with no CSS definition and no Tailwind match are highlighted as unused
- Create missing definitions — click a hover link or use the lightbulb Quick Fix to add a new rule to a stylesheet already imported in the file
- One-click navigation — jump directly to the source file to edit
No more switching between files, no more "where did I define this style?", no more memorizing Tailwind scales.
Quick Demo
Hover to reveal CSS definitions

See decoded Tailwind utilities

Click to jump to the definition

Features
| Feature |
Description |
| Hover Reveal |
Hover over any className="...", class="...", :class, [ngClass], or cn() / clsx() call to instantly see all matching CSS definitions. |
| Class Hierarchy View |
A Class Spy icon in the Activity Bar opens an element tree of the active JSX/TSX/HTML/Vue/Svelte/Astro file. Each element shows its classes; hover for the CSS, decoded Tailwind and the element's final combined styles, click to jump to it, and the selection follows your cursor. Classes are listed as their own rows with Go to Definition, Find All References and Create CSS Rule. Components can be expanded to show the elements they render, followed through imports, path aliases and barrel files. Right-click an element to copy its CSS selector (section.card > header > button.btn) or create a rule for it. |
| Problem Checks |
The hierarchy flags unknown classes, group-*/peer-* variants with no group/peer above them, BEM elements outside their block or modifiers without their base class, and conflicting utilities such as p-2 p-4 or flex hidden. Problem counts appear as badges, and a filter shows only the elements with problems, or only those using a given class. |
| Stylesheet Classes View |
Every stylesheet with the classes it defines and how often each is used. Unused classes are dimmed and can be shown on their own. |
| Tailwind Decoder |
Decodes Tailwind utilities into the CSS they generate — including variants (hover:, md:, dark:, group-hover:, peer-checked:, aria-*, data-*, [&>*]:, @container), opacity (bg-red-500/50), negative values (-mt-4), !important, and Tailwind v4 syntax (bg-(--brand), p-13, [mask-type:luminance]). |
Tailwind v4 @theme |
Custom colours, breakpoints and spacing declared in your project's @theme { … } blocks are picked up automatically, so bg-brand or tablet:flex decode correctly. |
| Autocomplete |
Class names from your stylesheets are suggested inside class / className / cn() — classes from the current file and imported stylesheets first, with the rule shown in the details pane. |
| CSS Modules |
Hover, F12 and autocomplete for styles.button, styles['btn-primary'] and camelCase access (styles.btnPrimary → .btn-primary), scoped to the imported .module.css/scss/sass/less file. |
| Find All References |
Shift+F12 on a class (in markup or on a selector in a stylesheet) lists every definition and usage across the workspace. |
| Unknown Class Detection |
Classes with no CSS definition in the workspace and no Tailwind match are flagged with a ❓ No CSS found section. |
| Grouped Output |
Custom CSS classes each get their own section. All Tailwind classes are combined into one ⚡ Tailwind block for clean, scannable output. |
| Workspace-wide Indexing |
Scans your entire workspace for .css, .scss, .sass, .less, and inline <style> blocks in .vue, .svelte, .astro, .html, .jsx, .tsx. Class usages are also found in .js / .ts files (e.g. cn() calls in helpers). |
| Path Aliases |
Stylesheet imports through tsconfig/jsconfig paths (e.g. @/styles/app.css) are resolved, plus the common @/ → src/ default. |
| Clickable References |
Every found definition includes a clickable link to its file and line number, opening in a new tab for quick navigation. |
| Edit in Place |
Click Edit next to any CSS rule to open the source file with the rule auto-selected — modify and save directly. |
| Live Updates |
File watchers keep the index current as you add, modify, or delete files — and stylesheets are re-indexed as you type, before you save. |
| Status Bar |
Shows how many classes are indexed; click it to re-index. |
| Reverse Lookup |
Hover over a class selector in CSS/SCSS/SASS/LESS files to see all template files where that class is used. |
SCSS & Resolution |
Nested selectors using & are expanded so &__title, &.active, &:hover, and descendant nesting resolve to their final class names. |
| Create Missing Definitions |
Undefined classes show a hover link; use Ctrl+. (Quick Fix) to insert a rule into an imported stylesheet. |
| Go to Definition |
Press F12 on a class to jump to its CSS/SCSS definition(s). Prefers imported stylesheets when multiple matches exist. |
| Configurable |
Customize utility function names, exclude patterns, and turn individual features on or off. |
Installation
From VS Code Marketplace
Search for "Class Spy" in the Extensions panel (Ctrl+Shift+X / Cmd+Shift+X) and click Install.
From VSIX
Download the latest .vsix from the Releases page, then run:
code --install-extension class-spy-1.0.0.vsix
Usage
1. Hover over a class attribute
// React / TSX
<div className="flex p-4 bg-red-500 text-white">
Hover anywhere inside "flex p-4 bg-red-500 text-white" and you will see:
**Class Spy**
`flex` `p-4` `bg-red-500` `text-white`
---
#### ⚡ Tailwind
```css
display: flex;
padding: 16px;
background-color: #ef4444;
color: #ffffff;
If you have custom CSS classes mixed in, each gets its own `📐` section:
```html
<div class="container flex p-4">
**Class Spy**
`container` `flex` `p-4`
---
#### 📐 `container`
*styles.css* | [Open] [Edit]
```css
.container {
max-width: 1200px;
margin: 0 auto;
}
⚡ Tailwind
display: flex;
padding: 16px;
2. Unknown classes are flagged
If a class has no CSS definition and is not a Tailwind utility, it appears in a ❓ No CSS found section:
<div class="container typo-class flex">
**Class Spy**
`container` `typo-class` `flex`
---
#### 📐 `container`
...
---
#### ⚡ Tailwind
display: flex;
---
#### ❓ No CSS found
`typo-class`
*These classes have no CSS definitions in the workspace and are not Tailwind utilities.*
3. Open a definition
Click Open styles.css:12 to jump to the rule in a new editor tab.
4. Edit a rule
Click Edit next to any definition. The source file opens in a split tab with the exact rule highlighted. Modify it and save with Ctrl+S.
5. Template literal & dynamic class support
Works inside JSX/TSX template literals and interpolations:
// Template literals with dynamic prefixes
<div className={`${base}-btn flex p-4`}>
// Ternary expressions — still decodes quoted strings
<div className={`${isActive ? 'bg-red-500' : 'bg-blue-500'} flex`}>
Static classes are always shown. Quoted string literals inside ${…} blocks are extracted as a best-effort, so you still see CSS definitions and Tailwind decoding for conditional classes.
6. Utility function support
Works inside cn(), clsx(), and classNames() calls (configurable — see Settings):
// shadcn/ui, Radix, etc.
<div className={cn("flex p-4", isActive && "bg-blue-600")}>
7. SCSS nesting with &
Class Spy expands nested SCSS/SASS/LESS selectors so hovering over the final class name finds the right rule, even when the same bare name exists in other files.
// styles.scss
.card {
&__title { font-size: 1.2rem; }
&.active { opacity: 1; }
&:hover { box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
}
// Component.tsx
<div className="card__title">Title</div>
Hovering card__title shows the &__title rule, and hovering active shows the &.active rule — no collisions with unrelated .title or .active classes elsewhere.
8. Create missing class definitions
If a class has no CSS definition, Class Spy offers two ways to add it:
- Hover link — in the
❓ No CSS found section, click Define .my-class.
- Quick Fix — place the cursor on the class and press
Ctrl+. / Cmd+. to choose Define .my-class in imported stylesheet.
The extension scans the current file for relative import './...scss', import styles from './...module.css', or import('./...css') statements, lets you pick one, and appends the rule with the cursor ready inside the new block.
// Button.tsx
import './button.scss';
export function Button() {
return <button className="btn-primary">Click</button>;
}
Hovering btn-primary and choosing Define appends to button.scss:
.btn-primary {
}
9. Go to Definition
Place the cursor on a class name and press F12 (or right-click → Go to Definition). Class Spy opens the matching CSS/SCSS rule. When multiple definitions exist, results from the current file and imported stylesheets appear first.
10. Tailwind variants & modifiers
Every class is decoded with its variants, so you can see exactly when a style applies:
<button class="md:hover:bg-sky-500/75 -mt-2 dark:text-white">
/* md:hover:bg-sky-500/75 */
@media (width >= 768px) {
&:hover {
background-color: rgb(14 165 233 / 0.75);
}
}
/* -mt-2 */
margin-top: -8px;
/* dark:text-white */
@media (prefers-color-scheme: dark) {
color: #ffffff;
}
11. Autocomplete
Start typing inside class="…", className="…" or cn("…") and Class Spy suggests the classes defined in your stylesheets. Classes from the current file and imported stylesheets are listed first, and the rule is previewed in the suggestion details.
12. CSS Modules
import styles from './Button.module.css';
<button className={styles.btnPrimary} /> // hover / F12 → .btn-primary in Button.module.css
<span className={styles['icon-left']} /> // bracket access works too
Type styles. to get completions for every class in the module. Names that aren't valid identifiers are inserted as styles['btn-primary'].
13. Find All References
Press Shift+F12 on a class — in markup, on a CSS module property, or on a selector in a stylesheet — to list every definition and usage in the workspace.
Supported Languages & Frameworks
- HTML (
.html, .htm)
- React (
.jsx, .tsx)
- Vue (
.vue)
- Svelte (
.svelte)
- Astro (
.astro)
- Angular templates (
[ngClass], [class], ng-class)
- MDX (
.mdx)
- CSS Modules (
*.module.css, .scss, .sass, .less)
Supported CSS Languages
.css
.scss
.sass
.less
- Inline
<style> blocks inside templates
Settings
Class Spy can be configured via VS Code settings (Ctrl+, → search "Class Spy"):
| Setting |
Type |
Default |
Description |
classSpy.utilityFunctionNames |
string[] |
["cn", "clsx", "classNames"] |
Utility function names to detect class strings in. Add your own (e.g. "tv", "tw") if you use a custom class merging function. |
classSpy.excludePatterns |
string[] |
["**/node_modules/**", "**/dist/**", "**/build/**", "**/.next/**", "**/out/**", "**/.turbo/**", "**/coverage/**"] |
Glob patterns to exclude from CSS indexing. Changes apply immediately. |
classSpy.completion.enabled |
boolean |
true |
Suggest class names inside class attributes, utility calls and after styles.. |
classSpy.tailwind.enabled |
boolean |
true |
Decode Tailwind classes in hovers. Turn off if you only use custom CSS or prefer another Tailwind extension's hovers. |
classSpy.showUnknownClasses |
boolean |
true |
Show the ❓ No CSS found section. |
classSpy.statusBar.enabled |
boolean |
true |
Show the indexed class count in the status bar. |
classSpy.hierarchy.followCursor |
boolean |
true |
Select the element under the cursor in the Class Hierarchy view. |
classSpy.hierarchy.showClassNodes |
boolean |
true |
List each class as its own row under its element. |
classSpy.hierarchy.showFinalStyles |
boolean |
true |
Show an element's combined declarations in its tooltip. |
classSpy.hierarchy.checks.groupPeer |
boolean |
true |
Flag group-* / peer-* variants without a matching group / peer. |
classSpy.hierarchy.checks.bem |
boolean |
true |
Flag BEM elements outside their block and modifiers without their base class. |
classSpy.hierarchy.checks.conflicts |
boolean |
true |
Flag Tailwind utilities that set the same property to different values. |
Test Suite
Class Spy includes a comprehensive test suite covering all core modules.
Run tests locally
npm install
npm run compile
npm test
Test Coverage
| Module |
Tests |
Coverage |
| Tailwind Decoder |
50+ utility classes decoded, arbitrary value syntax ([...]), variants, opacity/line-height modifiers, negatives, !important, v4 syntax and @theme tokens |
>90% |
| CSS Modules & Completion |
Module import detection, styles.x / styles['x'] references, camelCase mapping, scoped hovers, completion inside attributes and after styles. |
— |
| CSS Indexer |
Selector parsing (simple, compound, nested & expansion), inline <style> extraction, deduplication, file watcher updates, findUsages caching |
>85% |
| Hover Provider |
class / className / cn() extraction, grouped output (custom sections + combined Tailwind), unknown class detection, create-definition links, edge cases |
>80% |
| Import Resolver |
ES import parsing for CSS/SCSS/SASS/LESS, relative path resolution, deduplication |
>90% |
| CSS Usage Hover Provider |
Reverse lookup in CSS files, file grouping, line deduplication, truncation |
>75% |
| Extension |
Command registration, integration smoke tests |
>75% |
Development
Build
npm install
npm run compile
Watch
npm run watch
Lint
npm run lint
Package
npx vsce package
Publish
npx vsce publish
Contributing
Contributions are welcome! Please open an issue or pull request on GitHub.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
Support
If Class Spy saves you time and you want to keep it growing, consider supporting the project:

Your support helps fund new features, better Tailwind coverage, and more framework support.
License
MIT © Class Spy Contributors
Changelog
See CHANGELOG.md for release history.