A Ruby gem for generating harmonious color palettes from a single base color using color theory algorithms. Works as both a CLI tool and a Ruby library.
- Generate palettes using 5 color theory modes: complementary, analogous, triadic, tetradic, and shades
- Output in 3 formats: plain text, CSS custom properties, and JSON
- Full HEX, RGB, and HSL color conversion
- Usable as a CLI tool or embedded as a Ruby library
Add to your Gemfile:
gem 'ruby-chromatic'Then run:
bundle installOr install directly:
gem install ruby-chromatic# Generate a complementary palette (default)
chromatic generate "#3498db"
# Specify a mode
chromatic generate "#3498db" triadic
# Output as CSS custom properties
chromatic generate "#3498db" triadic --format css
# Output as JSON with 7 shades
chromatic generate "#e74c3c" shades --format json --steps 7
# Show version
chromatic versionAvailable modes:
| Mode | Description |
|---|---|
complementary |
2 colors opposite on the color wheel |
analogous |
3 colors adjacent on the color wheel |
triadic |
3 colors evenly spaced at 120 degrees |
tetradic |
4 colors evenly spaced at 90 degrees |
shades |
Lightness gradient from dark to light |
Available formats: text (default), css, json
require 'chromatic'
# Create a color
color = Chromatic::Color.from_hex('#3498db')
# Convert between formats
color.to_hex # => "#3498db"
color.to_rgb # => "rgb(52, 152, 219)"
color.to_hsl # => { h: 204.1, s: 69.9, l: 53.1 }
# Generate palettes
palette = Chromatic::Generator.complementary(color)
palette = Chromatic::Generator.triadic(color)
palette = Chromatic::Generator.shades(color, steps: 7)
# Format output
puts Chromatic::Formatter.css(palette)
puts Chromatic::Formatter.json(palette)
puts Chromatic::Formatter.text(palette)Example CSS output:
:root {
--triadic-1: #3498db;
--triadic-2: #db3498;
--triadic-3: #98db34;
}git clone https://github.com/sha-wrks/Ruby-Chromatic.git
cd Ruby-Chromatic
bundle install
bundle exec rspecContributions are welcome. Please read CONTRIBUTING.md before submitting a pull request.
To report a vulnerability, see SECURITY.md.
Released under the MIT License. Copyright (c) 2026 Yansha.