Converts RGB color values to a hexadecimal color string. Takes red, green and blue color components (0-255) and returns a hex color code. Useful for converting between color formats and generating color strings for CSS/HTML.
// default prefix "#"rgbToHex({ r: 255, g: 255, b: 255 }); // #ffffff Copy
// default prefix "#"rgbToHex({ r: 255, g: 255, b: 255 }); // #ffffff
// no prefixrgbToHex({ r: 0, g: 255, b: 0 }, ""); // 00ff00 Copy
// no prefixrgbToHex({ r: 0, g: 255, b: 0 }, ""); // 00ff00
default is "#"
string
Converts RGB color values to a hexadecimal color string.
Takes red, green and blue color components (0-255) and returns a hex color code.
Useful for converting between color formats and generating color strings for CSS/HTML.
Example
Example