stylesh
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

STYLESH

Description

Stylesh is a powerful and easy-to-use JavaScript and TypeScript library that enables developers to style text and add various decorative elements to console output. With Stylesh, you can apply colors to text and backgrounds, create dashed, double, solid, or custom borders, and even customize the border colors from a palette of 141 available colors. This library simplifies the process of enhancing console output for JavaScript and TypeScript developers, making debugging and logging more visually appealing and informative.

Logo

Examples

Installation

Installation is done using the npm install command:

$ npm install stylesh

Features

  • Text Styling: Change the color of the text to highlight important messages or errors.
  • Background Styling: Set background colors to emphasize specific sections of the output.
  • Border Styles: Add dashed, double, solid, or custom borders to console output.
  • Border Color Customization: Choose from 141 available colors to customize border colors.
  • Rounded Corners: Apply rounded corners to the borders for a polished look.
  • Easy to Use: Simple and intuitive API, allowing developers to style console output with minimal code.
  • Compatible: Works seamlessly with both JavaScript and TypeScript projects.

Usage

First, import the stylesh library into your project:

// Import the stylesh library
require("stylesh");
//or
import("stylesh");

Text color

1.single color: You can use Any of the 141 available colors, use color names

console.log("Important Message".color("green"));

2.multi colors:

Examples

  • red
  • yellow
  • green
  • blue
  • pink
  • orange
  • brown
  • purple
  • cyan
console.log("Important Message".multiColors("red");

Background color

1.single color: You can use Any of the 141 available colors, use color names

console.log("Important Message".bg("green"));

2.multi colors:

Examples

  • red
  • yellow
  • green
  • blue
  • pink
  • orange
  • brown
  • purple
  • cyan
console.log("Important Message".multiBg("red");

Border Styles

Examples

Solid Border

console.log("Error Message".color("red").createSolidBorder("red"));

Dashed Border

console.log("Hello".color("blue").createDashedBorder("blue"));

Rounded Corners

console.log("Hello".createRoundedBorder("red", "r"));

Double Border

console.log("Error Message".color("red").createDoubleBorder("red"));

Dotted Border

console.log("Error Message".color("red").createDottedBorder("red"));

Custom Border

console.log("Hello".color("aqua").createCustomBorder("=", "top", "red"));

Multiline Messages

console.log(
  "Important Information<>Additional Details<>Note: This is a multi-line message"
    .color("white")
    .createDottedBorder("green", "r")
);

Note

When specifying multiple lines, separate each line with <>

Customization

Border functions take two arguments: border color and text alignment direction.

  • Border Color: Any of the 141 available colors, use color names.
  • Text Alignment Direction: Use 'c' for center (default), 'l' for left, or 'r' for right alignment.

Examples

console.log(
  "Default dashed border with center alignment.".createDashedBorder("purple")
);
console.log(
  "Solid border in orange with left alignment.".createSolidBorder("orange", "l")
);
console.log(
  "Rounded border in tomato color with right alignment.".createRoundedBorder(
    "tomato",
    "r"
  )
);

the example result

Custom Border

  • Symbol: The character used to create the border.
  • Border Position: Use 'all', 'top', 'bottom', 'left', or 'right' to specify the position
  • Border Color: Any of the 141 available colors, use color names.

Examples

console.log(
  "Custom green border at the bottom.".createCustomBorder(
    "#",
    "bottom",
    "green"
  )
);
console.log(
  "Custom blue border on the left.".createCustomBorder("*", "left", "blue")
);
console.log(
  "Custom orange border on the right.".createCustomBorder(
    "@",
    "right",
    "orange"
  )
);

Abailable colors :

ConsoleStyler supports a variety of colors, including "red", "green", "blue", and many more. You can choose from 141 available colors to customize your console output.

Colors

Package Sidebar

Install

npm i stylesh

Weekly Downloads

2

Version

1.0.6

License

ISC

Unpacked Size

103 kB

Total Files

55

Last publish

Collaborators

  • omar-alghaish