ClassNames Go is a VS Code extension designed to assist developers in wrapping classname strings or to classNames() or clsx() or adding className attribute with classnames or clsx in React files.
It simplifies the process of wrapping class strings with the classnames or clsx library, allowing you to easily combine static Tailwind classes with dynamic CSS Module classes.
Features
🔄 One-Command Conversion: Convert className="..." to className={classNames("...")} or className={clsx("...")} instantly.
📦 Auto Import: Automatically detects if classnames or clsx is imported. If not, it adds import classNames from 'classnames' to the top of your file.
🎯 Migration Ready: Perfect for projects introducing Tailwind CSS into an existing CSS Modules architecture.
Usage
Open a React file (.tsx or .jsx).
Select the className attribute or place your cursor on it.
// Before
<div className="container flex-row"></div>
Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P).
Search and select ClassNames Go: Convert to ClassNames (Command ID: classnames-go.go).
The code will be transformed, and the import will be added if missing.
// After
import classNames from 'classnames';
// ...
<div className={classNames('container flex-row')}></div>;
Commands
Command
Description
classnames-go.go
Convert selected className string to classNames function wrapper
Requirements
Make sure the classnames package is installed in your project: