Ink is a lightweight TypeScript library that allows users to create beautiful colorized console.log outputs using ANSI escape codes. With Ink, you can easily apply various colors and styles to your console text, making your logs more readable and visually appealing.
npmjs: https://www.npmjs.com/package/@nktznl/ink
To install Ink, you can use npm or yarn:
npm install ink
or
yarn add ink
or
pnpm add ink
Ink provides a simple and intuitive API to colorize your console.log outputs. Below are some examples to get you started.
You can use basic colors to change the text color:
import { ink } from "ink";
console.log(ink.red.text("This is red text"));
console.log(ink.green.text("This is green text"));
console.log(ink.blue.text("This is blue text"));
Ink also supports bright colors for more vibrant text:
console.log(ink.brightRed.text("This is bright red text"));
console.log(ink.brightGreen.text("This is bright green text"));
console.log(ink.brightBlue.text("This is bright blue text"));
You can change the background color of the text as well:
console.log(ink.bgRed.text("This is text with a red background"));
console.log(ink.bgGreen.text("This is text with a green background"));
console.log(ink.bgBlue.text("This is text with a blue background"));
Ink allows you to combine multiple colors and styles:
console.log(ink.red.bgWhite.text("This is red text on a white background"));
console.log(
ink.brightGreen.bgBrightBlack.text(
"This is bright green text on a bright black background"
)
);
The ink object is a proxy that dynamically builds and applies color combinations to text.
text(text: string): string
Wraps the given text in the specified color codes.
text: The text to be colorized.
Example:
console.log(ink.red.text("This is red text"));
Contributions are welcome! Please open an issue or submit a pull request for any bugs or feature requests.
This library uses ANSI escape codes to colorize console output. For more information on ANSI escape codes, see ANSI escape code.
Enjoy using Ink to make your console logs more colorful and readable!