CSS Relative Color Generator
Create relative color variations using CSS color functions
Presets
Base Color
Color Space
Channel Transformations
Saved Configurations
Result Preview
Original#3498db
→
Transformed#3398db
Transformation: No transformation
Generated Syntax
hsl(from #3498db h s l)Color Variations
Lighten
Darken
Saturate
Desaturate
Complement
Grayscale
Generated CSS
/* CSS Relative Color Syntax - Generated by Brix340 Tools */
/* Base Color: #3498db */
/* Transformation: No transformation */
/* Basic Usage */
.element {
background-color: hsl(from #3498db h s l);
}
/* With CSS Custom Properties */
:root {
--color-base: #3498db;
--color-transformed: hsl(from var(--color-base) h s l);
}
/* Common Relative Color Transformations */
.lighten {
background-color: hsl(from #3498db h s calc(l + 20%));
}
.darken {
background-color: hsl(from #3498db h s calc(l - 20%));
}
.saturate {
background-color: hsl(from #3498db h calc(s + 30%) l);
}
.desaturate {
background-color: hsl(from #3498db h calc(s - 30%) l);
}
.complement {
background-color: hsl(from #3498db calc(h + 180) s l);
}
/* Advanced Transformations */
.grayscale {
background-color: hsl(from #3498db h 0% l);
}
.semi-transparent {
background-color: hsl(from #3498db h s l / 50%);
}
.warmer {
background-color: oklch(from #3498db l c calc(h - 30));
}
.cooler {
background-color: oklch(from #3498db l c calc(h + 30));
}
/* Interactive States */
.button {
--btn-color: #3498db;
background-color: var(--btn-color);
transition: background-color 0.2s;
}
.button:hover {
background-color: hsl(from var(--btn-color) h s calc(l + 10%));
}
.button:active {
background-color: hsl(from var(--btn-color) h s calc(l - 10%));
}
/* Fallback for Older Browsers */
.element {
background-color: #3498db; /* Fallback */
background-color: hsl(from #3498db h s l);
}
/* @supports Feature Detection */
@supports (background: hsl(from red h s l)) {
.modern-relative-color {
background-color: hsl(from #3498db h s l);
}
}
CSS Relative Color Syntax Reference
Basic Syntax
colorspace(from origin-color c1 c2 c3) colorspace(from origin-color c1 c2 c3 / alpha) /* Examples */ hsl(from red h s l) oklch(from blue l c h) rgb(from green r g b / 50%)
Channel References
- HSL: h, s, l (hue, saturation, lightness)
- HWB: h, w, b (hue, whiteness, blackness)
- RGB: r, g, b (red, green, blue)
- Lab: l, a, b (lightness, a-axis, b-axis)
- LCH: l, c, h (lightness, chroma, hue)
- OKLCH: l, c, h (perceptual lightness, chroma, hue)
Common Operations
/* Lighten */ hsl(from color h s calc(l + 20%)) /* Darken */ hsl(from color h s calc(l - 20%)) /* Saturate */ hsl(from color h calc(s + 30%) l) /* Complement */ hsl(from color calc(h + 180) s l) /* Semi-transparent */ hsl(from color h s l / 50%)
Browser Support
- Chrome 119+
- Firefox 128+
- Safari 16.4+
- Edge 119+
~85% global coverage (Dec 2024)
Use Cases
- Dynamic hover/active states
- Generating color scales
- Creating accessible contrasts
- Theme variations from single color
- Color manipulation without JavaScript
Tips
- Use OKLCH for perceptually uniform changes
- calc() works inside channel expressions
- Can cross color spaces (rgb from hsl color)
- CSS variables work as origin colors
- Always provide fallbacks for older browsers