December 08, 2019
I ran into an issue this week: needed to update the colour of a pseudo element (i.e.
::before) of an element.
My solution was to update the custom property which that pseudo element was using. It’s a rather simple solution, first select the document root element:
const root = document.documentElement;
Then update the custom property with the new value:
Here’s the working solution:
I’m a Brazilian front-end developer living in London. This website features some of my latest projects and my thoughts on anything web related.
You can find me on Twitter, Instagram, and LinkedIn.