Update CSS variable in a React Component

preview_player
Показать описание
Create a React Component that changes the value of CSS variables

#ReactHax
Рекомендации по теме
Комментарии
Автор

Hey I think the people who would be asking this question are React beginners like me. You're doing something more complex, and I don't even know things like why some of your CSS properties start with 2 hyphens (--some variable). If you're catering to moderate to advanced users that want to know how to do this stuff then it's a good tutorial, but the video should probably be named appropriately. If you're catering to beginners, then just show us how to change the width of an element through a React component (that's all I was looking for)

AlexHutchingsOfficial
Автор

I didn't know about document.documentElement.style.setProperty(), pretty cool! This means you could have one element change the CSS variable for your --primary-background-color and other such things to implement theme changes.

snwdn
visit shbcf.ru