contrastrast
Version:
A lightweight tool that parses color strings and recommends text contrast based on WCAG Standards
17 lines • 1.32 kB
TypeScript
import type { ContrastrastOptions } from "./contrastrastOptions.types.js";
/**
* Recommends to use either `light` or `dark` text based on the
* given background color.
*
* Color string can be HEX, RGB, or HSL
*
* @deprecated This method will go away in v2, we recommend switching to `Contrastrast(color).textContrast(bgColor)` for a more comprehensive and accurate comparison
*
* @param {String} bgColorString Color string of the background. Can be HEX, RGB, or HSL
* @param {ContrastrastOptions} options (Optional) Partial collection `ContrastrastOptions` that you wish you apply
* @param {"dark"|"light"} [options.fallbackOption="dark"] Fallback color recommendation, returns on error or unparsable color string. Defaults to `dark`
* @param {Boolean} [options.throwErrorOnUnhandled=false] Force option to throw error when invalid/unhandled color string is passed. Defaults to `false`
* @return {"dark"|"light"} Text color recommendation for given color string
*/
export declare const textContrastForBGColor: (bgColorString: string, options?: Partial<ContrastrastOptions>) => "dark" | "light";
//# sourceMappingURL=textContrastForBGColor.d.ts.map