Skip to content

Instantly share code, notes, and snippets.

@stekhn
Created April 25, 2024 07:22
Show Gist options
  • Save stekhn/e1f2468a8e2db4826fbf73fdb87a09d6 to your computer and use it in GitHub Desktop.
Save stekhn/e1f2468a8e2db4826fbf73fdb87a09d6 to your computer and use it in GitHub Desktop.
Outputs an array of color strings to the browser console and colors each string according to its hexadecimal or RGB value for visual debugging
const consoleColorLog = (colors: string[]) => {
const strings = colors.map((color: string) => `%c${color}`).join(" ");
const css = colors.map((color: string) => `color: ${color};`);
console.log.apply(console, [strings, css].flat());
};
// consoleColorLog(["#FFFFFF", "#AFD1F9", "#6CA4FF", "#006AFF", "#0515CD"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment