Lighten and darken functions help you make colors lighter or darker easily. This is useful to create different shades of the same color for your website design.
Lighten and darken functions in SASS
lighten($color, $amount) darken($color, $amount)
$color is the base color you want to change.
$amount is how much you want to lighten or darken, usually in percentages (e.g., 20%).
$light-blue: lighten(#007BFF, 20%);
$dark-red: darken(#FF0000, 15%);
button {
background-color: lighten(#28a745, 10%);
}p {
color: darken(#333333, 30%);
}This code creates a button with a blue background that is lighter than the base color. When you hover over the button, the background becomes darker. This gives a nice visual effect showing interaction.
@use 'sass:color'; $base-color: #3498db; .button { background-color: color.lighten($base-color, 20%); color: white; padding: 1rem 2rem; border: none; border-radius: 0.5rem; font-size: 1.2rem; cursor: pointer; transition: background-color 0.3s ease; } .button:hover { background-color: color.darken($base-color, 15%); }
Always use percentages for the amount to control how much lighter or darker the color becomes.
Lighten and darken work best with colors in hex, rgb, or named color formats.
Use these functions to keep your color scheme consistent and easy to adjust.
Lighten and darken functions adjust colors by making them lighter or darker.
They take a color and a percentage amount as inputs.
Use them to create hover effects, improve readability, and build color palettes.