Convert RGB to HEX as string

// default prefix "#"
rgbToHex({ r: 255, g: 255, b: 255 }); // #ffffff
// no prefix
rgbToHex({ r: 0, g: 255, b: 0 }, ""); // 00ff00
  • Parameters

    • rgb: {
          b: number;
          g: number;
          r: number;
      }
      • b: number
      • g: number
      • r: number
    • prefix: string = "#"

      default is "#"

    Returns string

    string