@skchr/color
    Preparing search index...

    Function alpha

    • Sets and retrieves the color token's alpha (or opacity).

      If the the amount argument is passed in, it sets the color token's alpha channel with the amount specified and returns the color as a hex string.

      • Also supports math expressions as a string for the amount parameter. For example *0.5 which means the value mult ly the current alpha by 0.5 and set the product as the new alpha value. In short currentAlpha * 0.5 = newAlpha. The supported symbols are * - / +.

      If the alpha channel is undefined, it defaults to 1.

      Type Parameters

      • Amount

      Parameters

      • color: ColorToken = "cyan"

        The color with the opacity/alpha channel to retrieve or set.

      • Optionalamount: Amount = undefined

        The value to apply to the opacity channel. The value is between [0,1].

      Returns Amount extends undefined ? number : ColorToken

      • The alpha channel value if amount is omitted, or the color token with the new alpha if amount is provided.
      import { alpha } from '@skchr/color'

      // Getting the alpha
      console.log(alpha('#a1bd2f0d'))
      // 0.050980392156862744

      // Setting the alpha

      const myColor = alpha('b2c3f1', 0.5)

      console.log(myColor)

      // #b2c3f180