A VS Code extension that colorizes Tailwind CSS prefixes for better readability.
- 🟣 Colorizes Tailwind prefixes (hover, focus, sm, lg, etc.)
- 🔵 Multiple built-in color themes
- 🟠 Fully customizable
- 🟡 API for third-party extensions to register custom themes
- 🟢 Web app to easily create your own themes (coming soon)
- Open Command Palette (
Ctrl+Shift+P
/Cmd+Shift+P
) - Type "Tailwind Rainbow: Select Theme"
- Choose from available themes
Configure which languages the extension should be active for. Default languages are:
{
"tailwindRainbow.languages": [
"html",
"javascript",
"typescript",
"javascriptreact",
"typescriptreact",
"vue",
"svelte",
"astro",
"php"
]
}
The extension uses VS Code's built-in language identifiers. You can find the language identifier for your file by:
- Opening the Command Palette (
Ctrl+Shift+P
/Cmd+Shift+P
) - Running "Change Language Mode"
- The items in the list are the language identifiers you can use
Create or override themes:
{
"tailwindRainbow.themes": {
"custom": {
"hover": {
"color": "#ff0000",
"fontWeight": "bold"
}
},
"default": {
"before": {
"enabled": false
}
}
}
}
Configure how class names are detected. By default, the extension will detect class names in all kinds of strings (single quotes, double quotes, template literals) to maximize compatibility across different coding styles and frameworks:
{
"tailwindRainbow.patterns": {
"default": {
"regex": "(?<=(['`\"]))((?:[^'`\"\\\\]|\\\\.)*?:[^'`\"]*(?:\\[[^\\]]*\\][^'`\"]*)*?)(?<!\\\\)(?=\\1)",
"enabled": true
}
}
}
Other extensions can register custom themes:
Wait for Tailwind Rainbow to be activated:
// package.json
{
"activationEvents": ["onCommand:tailwind-rainbow.loadThemes"]
}
Register your theme:
// extension.ts
import * as vscode from 'vscode';
export async function activate(context: vscode.ExtensionContext) {
const tailwindRainbow = vscode.extensions.getExtension<any>('esdete.tailwind-rainbow');
if (tailwindRainbow) {
tailwindRainbow.exports.registerTheme('myCustomTheme', {
xs: { color: '#ff00ff', fontWeight: 'bold' },
// ...
});
}
}
A web app to easily create your own themes is coming soon!
You have an idea for a new feature or found a bug? Feel free to open an issue or submit a pull request!
Apache 2.0 License - see the LICENSE file for details