Function isShortHex

  • Determines if a hex string is in CSS shorthand notation.

    Example

    isShortHex('#000') // Returns `true`
    isShortHex('0x000', '0x') // Returns `true`
    isShortHex('0x000000', '0x') // Returns `false`
    isShortHex('#000', '0x') // Returns `false`

    Parameters

    • val: string

      The hex string to test against.

    • prefix: HexStringPrefix = '#'

      Prefix of hex string.

    Returns boolean

    true if the hex string is in shorthand notation, false otherwise.