Function resolveToString

Like resolve, but returns a CSS-ready string representation.

element.style.backgroundColor = resolveToString(`red`);

Tries each parameter in turn, returning the value for the first that resolves. This can be useful for having fallback values.

// Try a CSS variable, a object property or finally fallback to red.
element.style.backgroundColor = resolveToString('--some-var', opts.background, `red`);
  • Parameters

    • Rest...colours: (undefined | Colourish)[]

      Array of colours to resolve

    Returns string