And now I want to use JS to dynamically change the tracks’ background based on the position of the thumb(value).
So I saw that I would have to use window.getComputedStyle function in order to access a pseudoelement.
And I use it but I am not getting a value of track pseudoelement when I call it but instead it is returning a styling from main input[type=range] element.
Here is JS:
I think it’s easier to create a custom element than styling a range slider, especially non-standard pseudo-elements hidden inside a shadow DOM.
One option I did see was using custom properties to set the value and change that in the JS. Not really sure how you are going to reasonably change the color based on the range slider value though.
Here is an extremely random example (removed the other CSS for brevity):