Answer the question
In order to leave comments, you need to log in
How can I change the background color to the user's choice?
There is a list with a set of colors (array: red, blue, etc.) and a paragraph. How can I make the background change when choosing a color?
If there is any good documentation with examples for beginners, I would be grateful for the link.
Answer the question
In order to leave comments, you need to log in
If you don’t have a question about how the user selects a color, then you are familiar with this part of the development, so you take the color value selected by the user (for example, the userColor variable) and put it, for example, in the useEffect hook
useEffect(() => {
document.body.style.backgroundColor = userColor;
}, [userColor]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question