Is Ansi Color SupportedIntroduction
Introduction
Detect terminal color support for ANSI, 256 colors, and TrueColor.
Last updated:
@visulima/is-ansi-color-supported
Detect terminal color support capabilities including ANSI 16 colors, 256 colors, and TrueColor (16 million colors).
Quick Start
import { isAnsiColorSupported } from "@visulima/is-ansi-color-supported";
const colorLevel = isAnsiColorSupported();
if (colorLevel >= 3) {
console.log("TrueColor supported!");
} else if (colorLevel >= 2) {
console.log("256 colors supported");
} else if (colorLevel >= 1) {
console.log("Basic ANSI colors supported");
} else {
console.log("No color support");
}Color Levels
0- No color support1- Basic 16 colors (ANSI)2- 256 colors3- TrueColor (16 million colors)