Subscribe on changes!

Hex color getting converted to RGB while rendering

avatar
Jan 13th 2021

I'm using vue3 on our email builder since some email clients don't support RGB/RGBA I will need to use HEX code but it seems vue3 convert Hex code to RGB while rendering

Version

3.0.5

Reproduction link

https://codesandbox.io/s/sad-cherry-vy3tr?file=/src/App.vue

Screenshot: Screenshot

Steps to reproduce

Just write an inline CSS color using hex code, it will render RGB color instead of rendering original hex

What is expected?

#ffffff

What is actually happening?

rgb(255, 255, 255)

avatar
Jan 13th 2021

see https://developer.mozilla.org/en-US/docs/Web/CSS/color

If the value is translucent, the computed value will be the rgba() corresponding one. If it isn't, it will be the rgb() corresponding one. The transparent keyword maps to rgba(0,0,0,0).

Meaning that no matter what is your input, the computed value always results in either rgb or rgba.

document.getElementById('xxx').style.color = "#f66"; this also will be convert to RGB.

avatar
Jan 13th 2021

@edison1105 Thanks for the Information.

avatar
Jan 13th 2021

maybe you can use color name instead hex-color: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value