E
E
Evgeny Zalivadny2021-10-04 15:37:48
Sass
Evgeny Zalivadny, 2021-10-04 15:37:48

How to check the "lightness" or "darkness" of a color in SCSS?

Suppose we have a button with a dark background and white text.
The background color may change to a lighter one, depending on the page settings.
How can you figure out that the background of the button has become too light (due to which the text color will merge) and you need to change the text color to a darker one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Flying, 2021-10-04
@Flying

Sass has a module for working with color.
In particular, you'll probably be interested in the blackness() and lightness() functions , but it's important to remember that they're blackness()only supported in Dart Sass.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question