Colors

The Colors enum provides ANSI escape codes for setting text foreground colors in terminal output. These values are used internally by ts-better-console to apply color styling via the s function and StyleOptions.

Enum Definition

The Colors enum maps color names to their corresponding ANSI escape sequences:

enum Colors {
  black = "\x1b[30m",
  red = "\x1b[31m",
  green = "\x1b[32m",
  yellow = "\x1b[33m",
  blue = "\x1b[34m",
  magenta = "\x1b[35m",
  cyan = "\x1b[36m",
  white = "\x1b[37m",
  gray = "\x1b[90m",
}

Available Colors

black
red
green
yellow
blue
magenta
cyan
white
gray

Usage

While the Colors enum is used internally, you typically set colors via the StyleOptions type when using the s function. You can also import and use the enum directly for advanced use cases:

import { s } from "ts-better-console";

// Using color names via StyleOptions
console.log(s("Hello in red!", { color: "red" }));
console.log(s("Hello in cyan!", { color: "cyan" }));
console.log(s("Hello in yellow!", { color: "yellow" }));

Want to support this project?

If you find ts-better-console useful and want to support its development, consider starring the GitHub repository or buying me a coffee! Your support helps me dedicate more time to improving the library and adding new features.

Want to contribute to this project?

Contributions are welcome! If you're interested in improving the library, fixing bugs, or adding new features, feel free to check out the GitHub repository and submit a pull request. Whether you're a seasoned developer or new to open source, your contributions can make a difference!