Relative Content

Tag Archive for javascriptreactjstypescriptreact-hooksreact-typescript

How to reassign 8 digit hex with alpha values to a 6 digit hex? accessible-colors

I’m using accessible-colors & react-color-palette, and what I’m trying to do is use the suggestAAColorVariant with the hexadecimal values of a foreground and background that also have alpha channels. (Ex. suggestAAColorVariant('#860f0fea', '#000000', true); ) When supplied with a 6 digit hex color code, it returns a color with a proper contrast value of 3.0, like #b21414. But the issue I am having is that it does not function as intended with a value using an alpha channel. it returns a color like #3a3aef with a different hue.