To set a message in the console with a custom color you can use the %c
directive.
Example:
javascript// Setting basic color console.log('%c Hi', 'color: blue'); // Setting hex color console.log('%c This is a pink message in hex.', 'color: #ffc0cb'); // Setting other properties like 'font-family' or 'font-size' console.log('%c Setting more properties.', 'color: #5a9e6f; font-family: Avenir; font-size: x-large');
Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.