A VSCode extension that displays color previews for CSS custom properties (variables) that use RGB or RGBA format.
- π¨ Color Background Highlighting: Shows colored backgrounds for CSS variables and Tailwind classes
- π₯ Decoration Style Choice: Display colors as a full highlight or a small inline color swatch
- π‘ Hover Tooltips: Rich per-context tooltips showing color swatches and RGB values for every detected context (
.light,.dark, etc.) β works on definition lines and usages alike - π― Tailwind CSS Support: Detects and shows colors for Tailwind utility classes
- π Multi-Context Support: Detect and switch between light/dark/custom color modes
- ποΈ File Type Control: Choose where decorations appear (
css,ts,tsx,js,jsx) - π Auto-Refresh: Updates when CSS files change, preserving multi-file context data
- β‘ Optimized Performance: esbuild bundling, debounced updates, LRU caching, pre-compiled patterns, O(1) color lookups
- π VSCode Web Compatible: Works on github.dev and vscode.dev
- π Multi-File Support: Works in TypeScript, React, JavaScript, and CSS files
/* RGB format (space-separated) */
--neutral-bg: 248 250 252;
/* RGBA format (with opacity using /) */
--topologyHighlightPulse: 87 91 239 / 0.2;/* Direct usage */
background: var(--neutral-bg);
/* Wrapped in color functions */
fill: rgba(var(--content-highlight));
stroke: rgb(var(--neutral-outline));// In React/TypeScript files
<div style={{ background: 'var(--neutral-bg)' }} />
<rect fill="rgba(var(--content-highlight))" />// Standard Tailwind colors
<div className="text-red-500 bg-blue-200 border-green-300">
// ^^^^^^^^^^^^ - Shows red color
// ^^^^^^^^^^^ - Shows blue color
// ^^^^^^^^^^^^^^^^ - Shows green color
// Custom Tailwind colors (from your tailwind.config.js)
<div className="text-txt-primary bg-card border-separator">
// ^^^^^^^^^^^^^^^^ - Shows your custom color
// ^^^^^^^ - Shows your custom color
// ^^^^^^^^^^^^^^^^^ - Shows your custom color
// Gradient colors
<div className="from-purple-500 to-pink-500">
// ^^^^^^^^^^^^^^^ - Shows purple
// ^^^^^^^^^^^ - Shows pinkSupported Tailwind prefixes:
text-- Text colorsbg-- Background colorsborder-- Border colorsfrom-,to-,via-- Gradient colorsring-- Ring colorsdivide-- Divider colorsdecoration-,accent-,caret-,outline-- Other color utilitiesfill-,stroke-- SVG colors
- Open any CSS file containing CSS custom properties
- Color squares will automatically appear in the gutter and inline for detected color variables and Tailwind classes
- Hover over a variable name, its value, or a
var(--name)usage to see the resolved color in a tooltip β with per-context swatches if.light/.darkcontexts are defined
If your CSS has colors defined in different contexts:
.light {
--text-primary: 51 65 85; /* Dark text for light backgrounds */
}
.dark {
--text-primary: 226 232 240; /* Light text for dark backgrounds */
}Switch between contexts:
- Press
Cmd+Shift+P - Type "True Colors: Switch Color Mode"
- Select:
auto,light,dark, or any detected context - All colors update instantly!
Or use Settings:
- Open Settings (
Cmd+,) - Search "True Colors"
- Set Color Mode to your preferred context
The extension automatically detects ANY class-based contexts (.theme-blue, .mobile, .print, etc.)
Control which file types receive decorations:
Command palette flow (recommended):
- Press
Cmd+Shift+P - Run
True Colors: Switch File Types - Toggle file types (
css,ts,tsx,js,jsx) - Changes apply instantly
Settings flow:
- Open Settings (
Cmd+,) - Search
trueColors.enabledLanguages - Set a subset such as:
"trueColors.enabledLanguages": ["css", "tsx", "jsx"]Supported values:
csststsxjsjsx
Choose how color decorations are rendered next to your code:
highlight(default) β the entire token is filled with the color as its background, with contrasting text so it stays readable.patchβ a small square color swatch appears inline before the token; the text itself stays completely unstyled.
Command palette flow (recommended):
- Press
Cmd+Shift+P - Run
True Colors: Switch Decoration Style - Pick
highlightorpatch - Style updates instantly across all open editors
Settings flow:
- Open Settings (
Cmd+,) - Search
trueColors.decorationStyle - Set the value:
"trueColors.decorationStyle": "patch"code --install-extension true-colors-0.0.4.vsixOr via VSCode: Extensions β ... β Install from VSIX
- Clone or download this extension
- Run
npm installto install dependencies - Run
npm run esbuild:prodto build with esbuild - Run
npm run packageto create the VSIX file - Install the generated
.vsixfile
# Install dependencies
npm install
# Build with esbuild (development)
npm run esbuild
# Watch mode for development (auto-rebuild on changes)
npm run watch
# Build for production (minified)
npm run esbuild:prod
# Package extension for distribution
npm run package
# Test the extension
Press F5 in VSCodeThis extension uses esbuild for fast, optimized bundling:
- β‘ 600x faster builds compared to traditional TypeScript compilation
- π¦ 85% smaller bundle size - from 140KB (12 files) to 20KB (1 file)
- π VSCode Web compatible - works on github.dev and vscode.dev
- π₯ Hot reload - instant rebuilds during development
Contributions are welcome! If you'd like to contribute:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Found a bug or have a feature request? Please open an issue on GitHub.
If you find this extension helpful, please:
- β Star the repository
- π Leave a review on the VS Code Marketplace
- π Report issues to help improve the extension
Aryak Lahane
- GitHub: @ark2002
MIT - see LICENSE file for details