Skip to main content

hexToRgb

Callable

  • hexToRgb(hex: string): Rgb | null

  • Converts a hexadecimal color code to its RGB equivalent.

    @example
    hexToRgb('#ffffff') // { r: 255, g: 255, b: 255, a: undefined }

    Parameters

    • hex: string

      The hexadecimal color code to convert.

    Returns Rgb | null

    An object containing the red, green, and blue values of the color, or null if the input is not a valid hexadecimal color code.