Adjust-hue helps you change a color's shade by rotating its color wheel position. This lets you create new colors easily without picking them manually.
Adjust-hue for color rotation in SASS
color.adjust-hue($color, $degrees)$color is the original color you want to change.
$degrees is how much you rotate the color on the color wheel. Positive values rotate clockwise, negative values rotate counterclockwise.
$new-color: color.adjust-hue(#ff0000, 90deg);
$new-color: color.adjust-hue(#00f, -45deg);
$new-color: color.adjust-hue(rgba(255, 0, 0, 0.5), 180deg);
This code sets a button with a tomato red background. When you hover over it, the background color changes by rotating the hue 120 degrees, creating a fresh greenish color. The transition makes the color change smooth.
@use 'sass:color'; $base-color: #ff6347; // tomato red $rotated-color: color.adjust-hue($base-color, 120deg); .button { background-color: $base-color; color: white; padding: 1rem 2rem; border: none; border-radius: 0.5rem; font-size: 1.25rem; cursor: pointer; transition: background-color 0.3s ease; } .button:hover { background-color: $rotated-color; }
Adjust-hue works best with colors in the HSL color space internally.
Rotation is circular, so 360deg rotation returns the original color.
The angle must be specified with a unit like 'deg' (e.g., 90deg).
Use adjust-hue to rotate a color's hue on the color wheel.
This helps create color variations easily and keeps color harmony.
Positive degrees rotate clockwise, negative degrees rotate counterclockwise.