ColorizeInstallation

Installation

How to install and set up @visulima/colorize in your project.

Last updated:

Installation

Package Manager

Install @visulima/colorize using your preferred package manager:

npm install @visulima/colorize

Requirements

  • Node.js: 22.13 or higher
  • TypeScript: 5.0+ (optional, for TypeScript projects)

Import Methods

Node.js (ESM)

// Default import
import colorize from "@visulima/colorize";

// Named imports (recommended)
import { red, green, blue, bold, hex } from "@visulima/colorize";

Node.js (CommonJS)

// Default import
const colorize = require("@visulima/colorize");

// Named imports
const { red, green, blue, bold, hex } = require("@visulima/colorize");

Browser

For browser environments, use the dedicated browser export:

// ESM default import
import colorize from "@visulima/colorize/browser";

// ESM named imports
import { red, green, blue } from "@visulima/colorize/browser";

Important: Browser version returns an array format for console styling. Use the spread operator:

import { green } from "@visulima/colorize/browser";

console.log(...green("Success!")); // Note the spread operator

Subpath Exports

The package provides several specialized exports for advanced features:

// Template literals
import template from "@visulima/colorize/template";

// Gradient support
import { gradient, multilineGradient } from "@visulima/colorize/gradient";

// Utility functions
import { strip } from "@visulima/colorize/utils";

Verification

Verify your installation by running a simple color test:

import { green, red, blue } from "@visulima/colorize";

console.log(green("✓ Installation successful!"));
console.log(blue("ℹ Colorize is ready to use"));
console.log(red.bold("● Colors are working"));

If you see colored output, the installation is successful!

TypeScript Support

TypeScript definitions are included automatically. No additional @types packages are needed.

import type { ColorizeType } from "@visulima/colorize";

// Full type checking and autocomplete
const colorize: ColorizeType = (await import("@visulima/colorize")).default;

Environment Variables

Colorize automatically detects and respects color support through environment variables:

  • NO_COLOR - Disables all colors when set to any value
  • FORCE_COLOR - Forces color output (values: 0, 1, 2, 3)
  • COLORTERM - Detects TrueColor support (value: truecolor)

CLI flags are also supported:

  • --no-color - Disables colors
  • --color - Forces color output

Next Steps

Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues