Open dmytro-lymarenko opened 4 years ago
Same here, I only use variable to customize my components color, I would really like this feature.
UP! I would also like this feature.
As long as your variable is a hex value, you can pull the value from JS.
window
.getComputedStyle(document.documentElement)
.getPropertyValue('--switch-on-color')
.trim()
As @sec0ndhand mentioned you could extract the hex values from the CSS variables and then input them as props.
The question is whether this should be done inside the library for convenience sake and I'm leaning towards no. A couple of problems come to mind:
:root
, in which case @sec0ndhand's snippet will fail.
Allow offColor, onColor, offHandleColor and onHandleColor to accept css variables, not only hex-colors.
In our project we use css vars to handle themes and we use them to customize components. But react-switch component doesn't allow to do this.
I would like to use switch component like this: