Skip to main content

Terminal color support detection package

This package works with Node.js, DenoIt is unknown whether this package works with Cloudflare Workers, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
100%
Published
11 months ago (2.1.0)

🎨 Color support

Terminal color support detection package.
Supports NO_COLOR and FORCE_COLOR.

🌈 Usage

import { ColorSupport, getColorSupport } from "@crayon/color-support";

const colors = await getColorSupport();
console.log(colors); // Prints amount of colors supported by current terminal

switch (colors) {
  case ColorSupport.TrueColor:
    console.log("over 16mil colors!");
    break;
  case ColorSupport.HighColor:
    console.log("255 colors");
    break;
  case ColorSupport.FourBit:
    console.log("16 colors..");
    break;
  case ColorSupport.ThreeBit:
    console.log("8 colors :/");
    break;
  default:
    console.log("No colors :(");
    break;
}

🖍 Crayon

This module is made as a first party extension for Crayon, terminal styling package.

📝 Licensing

This project is available under MIT License conditions.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@crayon/color-support

Import symbol

import * as color_support from "@crayon/color-support";
or

Import directly with a jsr specifier

import * as color_support from "jsr:@crayon/color-support";

Add Package

pnpm i jsr:@crayon/color-support
or (using pnpm 10.8 or older)
pnpm dlx jsr add @crayon/color-support

Import symbol

import * as color_support from "@crayon/color-support";

Add Package

yarn add jsr:@crayon/color-support
or (using Yarn 4.8 or older)
yarn dlx jsr add @crayon/color-support

Import symbol

import * as color_support from "@crayon/color-support";

Add Package

npx jsr add @crayon/color-support

Import symbol

import * as color_support from "@crayon/color-support";

Add Package

bunx jsr add @crayon/color-support

Import symbol

import * as color_support from "@crayon/color-support";