Skip to main content

Terminal color support detection package

Works with
It is unknown whether this package works with Bun
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 Browsers
JSR Score
100%
Published
2 months ago (2.0.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.

Add Package

deno add @crayon/color-support

Import symbol

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

Add Package

npx jsr add @crayon/color-support

Import symbol

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

Add Package

yarn dlx jsr add @crayon/color-support

Import symbol

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

Add Package

pnpm dlx jsr add @crayon/color-support

Import symbol

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

Add Package

bunx jsr add @crayon/color-support

Import symbol

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