How do I change the colour of an output with console.log
Hey @Daniel,
-
If you want the logs to be in red, then use
console.error()
. -
If you want the logs to be in yellow, then use
console.warn()
. -
Alternatively, you can use styles within a
console.log
statement like this:
console.log('%c Hello World! ', 'background: black; color: white');
it doesn’t work. Here is what I get:
%c Hello World! background: black; color: white
@khalby786 Please help
Works for me…
Are you using this for the Glitch Logs or Chrome DevTools?
I’m using glitch console
Oh, what I said above would only apply for Chrome DevTools. So if you’re using the Glitch Logs, your only options would be console.error()
and console.warn()
.
Ohhhhhh thanks for the help anyway
In the logs view, only console.error()
and console.warn()
change the text color, but in the actual console, you can use a library like chalk
for coloring, chalk detects if the console/logs support it and send colored or not messages accordingly.