The RGBA or RGB string to convert.
Whether to remove the alpha channel from the resulting hexadecimal color value. Default is false.
The hexadecimal color value.
Error if the input RGBA/RGB string is invalid.
console.log(RGBAToHexAlpha('rgba(255, 0, 0, 1)')); // Output: '#ff0000ff'
console.log(RGBAToHexAlpha('rgb(255, 0, 0)')); // Output: '#ff0000'
console.log(RGBAToHexAlpha('rgba(255, 0, 0, 0.5)'));// Output: '#ff000080'
console.log(RGBAToHexAlpha('rgba(255, 0, 0, 0.5)', true)); // Output: '#ff0000'
Converts an RGBA or RGB string to a hexadecimal color value with optional alpha channel.