2024-02-15
4443
#css
Idorenyin Obong
14833
Feb 15, 2024 â‹… 15 min read

How to use CSS variables like a pro

Idorenyin Obong Software engineer with a flair for writing.

Recent posts:

Understanding The Latest Webkit Features In Safari 17.4

Understanding the latest Webkit features in Safari 17.4

The Safari 17.4 update brought in many modern features and bug fixes. Explore the major development-specific updates you should be aware of.

Rahul Chhodde
May 16, 2024 â‹… 10 min read
Using Webrtc To Implement Peer To Peer Video Streaming In A Node Js Project

Using WebRTC to implement P2P video streaming

Explore one of WebRTC’s major use cases in this step-by-step tutorial: live peer-to-peer audio and video streaming between systems.

Oduah Chigozie
May 16, 2024 â‹… 18 min read
Htmx Vs React

htmx vs. React: Choosing the right library for your project

Both htmx and React provide powerful tools for building web apps, but in different ways that are suited to different types of projects.

Temitope Oyedele
May 15, 2024 â‹… 9 min read
Exploring The Top Pair Programming Tools

Exploring the top 5 pair programming tools

Review the top five pair programming tools, including how to use them, their features, drawbacks, pricing models, and more.

Elijah Asaolu
May 15, 2024 â‹… 8 min read
View all posts

2 Replies to "How to use CSS variables like a pro"

  1. I strangely couldn’t retrieve the value from documentElement via getPropertyValue, as it was not set on that element. Setting the value via javascript to black works fine, and then retrieval works and comes back as black. (I had one variable definition in css under :root in header style definitions – red, and one value set on the html element itself via chrome devtools – black)
    Instead using getComputedStyle worked okay as it supports the pseudo selector as second argument and I was able to retrieve the original css value of red, or any overloaded value as appropriate.

    window.getComputedStyle(window.document.documentElement,”:root”).getPropertyValue(‘–joy-colour’)

Leave a Reply