colx
v1.1.1
Published
Scan and visualize Tailwind arbitrary color values with CSS variable consolidation suggestions
Maintainers
Readme
Tailwind Color Visualizer
A CLI tool that scans TypeScript/JSX files for Tailwind arbitrary color values, visualizes them in a coolors.co-style web UI, and provides suggestions for CSS variable consolidation and color merging opportunities.
Features
- 🔍 Scan
.tsxand.jsxfiles for Tailwind arbitrary color values - 🎨 Visualize colors in a beautiful web interface (similar to coolors.co)
- 💡 Suggest CSS variable consolidation for duplicate colors
- 🔬 Detect similar colors and suggest merges using Delta E color difference
- 📊 Statistics about color usage across your codebase
Installation
npm install -g colxOr use with npx (no installation required):
npx colx [directory]Usage
Basic Usage
Scan the current directory:
colxOr specify a directory:
colx ./srcOptions
--port <number>- Server port (default: 6969)--no-open- Don't open browser automatically--threshold <number>- Color similarity threshold for merge suggestions (default: 5)
Examples
# Scan a specific directory
colx ./my-project/src
# Use a custom port
colx --port 8080
# Don't open browser automatically
colx --no-open
# Adjust similarity threshold (lower = more strict)
colx --threshold 3Supported Color Formats
The tool detects Tailwind arbitrary values in the following formats:
- Hex:
bg-[#ff5733],text-[#ABC] - RGB:
bg-[rgb(255,87,51)] - RGBA:
bg-[rgba(255,87,51,0.5)] - HSL:
bg-[hsl(9,100%,50%)] - HSLA:
bg-[hsla(9,100%,50%,0.5)]
What It Does
- Scans your codebase for
.tsxand.jsxfiles - Extracts all Tailwind arbitrary color values
- Normalizes colors to hex format for comparison
- Analyzes color similarities using Delta E (CIEDE2000)
- Suggests CSS variable consolidation for duplicate colors
- Suggests color merges for visually similar colors
- Displays everything in a beautiful web interface
Output
The tool launches a web server and opens your browser to display:
- Color Palette: Grid view of all unique colors found
- Color Details: Click any color to see where it's used
- Filter by Utility Class: Filter colors by bg, text, border, etc.
- Merge Suggestions: Groups of similar colors that could be merged
Development
# Install dependencies
npm install
# Build TypeScript
npm run build
# Run in development mode (with Bun)
bun run src/index.ts
# Or with Node.js
npm run devRequirements
- Node.js >= 16 (or Bun)
- TypeScript projects with
.tsxor.jsxfiles
