Function hexToRgba

  • Converts a CSS hex color value to an RGB or RGBA color value.

    Parameters

    • hex: string

      The hex value to convert. ('123456', '#123456', '123', '#123')

    • alpha: string | number = 1

      An optional alpha value to apply. ('0.5', '0.25', 0.5, 0.25)

    Returns string

    An RGB or RGBA color value. ('rgb(11, 22, 33)', 'rgba(11, 22, 33, 0.5)')