Styles

The Styles enum provides ANSI escape codes for applying text decoration styles in terminal output. These values are used internally by ts-better-console to apply text styling via the s function and StyleOptions.

Enum Definition

The Styles enum maps style names to their corresponding ANSI escape sequences:

enum Styles {
  bold = "\x1b[1m",
  italic = "\x1b[3m",
  underline = "\x1b[4m",
  strikethrough = "\x1b[9m",
}

Available Styles

  • bold Makes text bold
  • italic Makes text italic
  • underline Makes text underlined
  • strikethrough Makes text strikethrough

Usage

While the Styles enum is used internally, you typically apply styles via the styles array in StyleOptions 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 styles via StyleOptions
console.log(s("Bold text", { styles: ["bold"] }));

console.log(s("Bold and italic", {
styles: ["bold", "italic"],
}));

console.log(s("Underlined red", {
color: "red",
styles: ["underline"],
}));

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!