React Template Literal FormatterA VS Code extension for keeping React What is React Template Literal Formatter?React Template Literal Formatter is a lightweight VS Code extension designed for React and Tailwind CSS workflows. It makes
The goal is simple: less formatting work, cleaner JSX. ✨ Features⚡ Instant
|
| Feature | Behavior |
|---|---|
| Long class lists | Wraps classes across multiple lines |
| Line length | Targets approximately 70 characters |
| Indentation | Keeps formatting relative to the JSX element |
| Closing syntax | Aligns the closing `}` with the opening tag |
| Dynamic expressions | Preserves JavaScript expressions |
| Existing formatting | Avoids unnecessarily changing your code |
🧠 Dynamic Classes Stay Dynamic
The formatter is designed to work with real-world React code, not just static Tailwind strings.
For example:
<div className={`
flex items-center justify-center
${isActive ? 'opacity-100' : 'opacity-0'}
`}>
Expressions such as:
${isActive ? 'opacity-100' : 'opacity-0'}
remain intact.
Your JavaScript logic stays yours. The formatter only handles the presentation.
🚀 Usage
Format from the Context Menu
Right-click inside a JavaScript, JSX, TypeScript, or TSX file and select:
Format className to
{``}
Format from the Status Bar
You can also use the:
className → {``}
button in the VS Code status bar.
📁 Supported Languages
The extension activates automatically for React-compatible files:
| Language | File Types |
|---|---|
| JavaScript | .js |
| JavaScript React | .jsx |
| TypeScript | .ts |
| TypeScript React | .tsx |
📦 Installation
VS Code
- Open VS Code
- Open Extensions with
Ctrl+Shift+X/Cmd+Shift+X - Search for React Classname Formatter
- Select Install
Command Line
code --install-extension react-classname-formatter
🧩 Why Template Literals?
Template literals make it convenient to combine Tailwind classes with JavaScript expressions:
<div className={`
flex items-center
${isActive ? 'bg-blue-500' : 'bg-gray-500'}
`}>
React Classname Formatter takes that approach and makes the resulting JSX easier to scan and maintain.
It is intentionally focused on formatting and developer experience, rather than trying to replace larger Tailwind tooling or class-merging libraries.
🤝 Contributing
Contributions, bug reports, and feature requests are welcome.
Development
git clone https://github.com/your-username/react-classname-formatter.git
cd react-classname-formatter
npm install
Create a feature branch:
git checkout -b feat/your-feature
Commit your changes:
git commit -m "feat: add my feature"
Push your branch:
git push origin feat/your-feature
Then open a Pull Request.
📄 License
Distributed under the MIT License.
See LICENSE for the full license text.
Made with ❤️ for developers who care about the little things.