@dragonspark/chroma-kit
    Preparing search index...

    Function hslFromCSSString

    • Parses a CSS HSL color string into an HSLColor object.

      Supports both comma and space syntax, as well as both hsl() and hsla() formats:

      • hsl(120, 100%, 50%)
      • hsla(120, 100%, 50%, 0.5)
      • hsl(120 100% 50%)
      • hsl(120 100% 50% / 0.5)

      The function handles:

      • Hue values in degrees (0-360, normalized if outside this range)
      • Saturation and lightness as percentages (0-100%)
      • Optional alpha value (0-1 or 0-100%)
      • Both comma-separated and space-separated formats
      • Whitespace flexibility according to CSS specifications

      Parameters

      • src: string

        The CSS HSL color string to parse

      Returns HSLColor

      The parsed HSL color object

      If the string format is invalid