How to use the supports-color.has16m function in supports-color

To help you get started, we’ve selected a few supports-color examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / supports-color_v3.x.x / test_supports-color_v3.x.x.js View on Github external
import supportsColor from 'supports-color';

if (supportsColor) {
  console.log('Terminal supports color');

  if (supportsColor.hasBasic) {
    const level: number = supportsColor.level;
    console.log('Terminal has basic color support', level);

  if (supportsColor.has256) {
    console.log('Terminal supports 256 colors');

  if (supportsColor.has16m) {
    console.log('Terminal supports 16 million colors (truecolor)');

  // $ExpectError

  // $ExpectError
  (supportsColor.level: string);