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

1.0.2 • Public • Published

chalk-mate

Tests Codacy Badge Codacy Badge GitHub issues GitHub license

NPM

illustration

A library that extends the chalk.js library by allowing you to apply color and style to HTML-like templates.

Installation

npm install chalk-mate

Usage

import chalkMate from 'chalk-mate'

const styled = chalkMate(`<red>Hello</red> <green>World</green>`)

console.log(styled)

Output

output

Foreground Color

The foreground color can be applied:

  1. By using the color name as the tag name.
  2. By using the color attribute.

Color Names

CSS color names are supported. See CSS Color Names for a list of supported color names.

<red>Hello World</red>
<text color="red">Hello World</text>

Hexadecimal Color Codes

<text color="#ff0000">Hello World</text>

RGB Color Codes

<text color="255, 0, 0">Hello World</text>

Background Color

The background color can be applied:

  1. By using the bg- prefix before the color name as the tag name.
  2. By using the bg attribute.

Color Names

CSS color names are supported. See CSS Color Names for a list of supported color names.

<bg-red>Hello World</bg-red>
<text bg="red">Hello World</text>

Hexadecimal Color Codes

<white bg="#ff0000">Hello World</white>

RGB Color Codes

<white bg="255, 0, 0">Hello World</white>

Text Styles

The following text styles are supported:

  1. Bold
  2. Dim
  3. Italic
  4. Underline
  5. Inverse
  6. Hidden
  7. Strikethrough
  8. Visible

See modifiers in chalk.js for more information.

They can be applied:

  1. By using the style name as the tag name.
  2. By using the name of the style as the attribute.
<bold>Hello World</bold>
or
<text bold>Hello World</text>
<italic>Hello World</italic>
or
<text italic>Hello World</text>

Nesting

You can nest tags within tags.

<red>Hello <bold>World</bold></red>

Combining Styles and Colors

You can combine styles and colors.

<bg-red color="white" underline>Hello <bold italic color="blue" bg="white">World</bold></bg-red>

License (MIT)

Copyright © Moses Gitau All rights reserved.

Find a copy of the License here

Buy Me A Coffee

Package Sidebar

Install

npm i chalk-mate

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

31.7 kB

Total Files

30

Last publish

Collaborators

  • gitaumoses4