# @open-tech-world/es-cli-styles

> Add CLI styles to text.

Latest version **0.3.0** (published 2021-08-11) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @open-tech-world/es-cli-styles
pnpm add @open-tech-world/es-cli-styles
yarn add @open-tech-world/es-cli-styles
bun add @open-tech-world/es-cli-styles
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2021-08-11 |
| First published | 2021-08-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^12.22.0 \|\| ^14.17.0 \|\| >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 16.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Thanga Ganapathy |
| Maintainers | ganapathy |
| Keywords | cli, style, string, text, color, colour |

## Links

- npm: https://www.npmjs.com/package/@open-tech-world/es-cli-styles
- Repository: https://github.com/open-tech-world/es-cli-styles
- Homepage: https://github.com/open-tech-world/es-cli-styles#readme
- Issues: https://github.com/open-tech-world/es-cli-styles/issues
- npm.io page: https://npm.io/package/@open-tech-world/es-cli-styles

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 0.3.0 (latest) — 2021-08-11
- 0.2.0 — 2021-08-07
- 0.1.2 — 2021-08-04
- 0.1.1 — 2021-08-04
- 0.1.0 — 2021-08-04

## README

<div align="center">

# @open-tech-world/es-cli-styles
[![Build](https://github.com/open-tech-world/es-cli-styles/actions/workflows/build.yml/badge.svg)](https://github.com/open-tech-world/es-cli-styles/actions/workflows/build.yml) [![CodeFactor](https://www.codefactor.io/repository/github/open-tech-world/es-cli-styles/badge)](https://www.codefactor.io/repository/github/open-tech-world/es-cli-styles)
</div>

> Add CLI styles to text.

## Features

✔️ 24-Bit Colors (True Color)

✔️ Nested Styles

## Supported Styles

✔️ Foreground Colors

✔️ Background Colors

✔️ Bold

✔️ Dim

✔️ Italic

✔️ Underline

✔️ Inverse

✔️ Strikethrough

## Installation

Using npm

```shell
npm install @open-tech-world/es-cli-styles
```

Using Yarn

```shell
yarn add @open-tech-world/es-cli-styles
```

## Usage

```ts
import { style } from '@open-tech-world/es-cli-styles';

style('~styleName[.styleName...]{Text}');
```

## Examples

Using foreground color name

```ts
console.log(style('I like 🍊 ~orange{oranges}'))
```
![](assets/orange-color.png)

Using multiple colors

```ts
console.log(style('An ~red{apple} is red but the ~green{leaves} are green, came in a blue ~blue{box}'))
```
![](assets/multiple-colors.png)

Nested colors

```ts
console.log(style('~blue{This is a long blue text with some ~red{red} & ~green{green} color in it}'))
```
![](assets/nested-colors.png)

Composing different styles

```ts
console.log(style('~bold.white.bgGreen{ PASS }'))
```
![](assets/bg-color.png)

Inverse colors

```ts
console.log(style('~inverse.red.bgWhite{ FAILED }'))
```
![](assets/inverse.png)

Faint, decreased intensity, or dim text

```ts
console.log(style('~dim{TEXT}'))
```
![](assets/dim-text.png)

Italic fonts

```ts
console.log(style('~italic.fuchsia.bold.bgWhite{ Beautiful Text }'))
```
![](assets/italic-text.png)

Underlined texts

```ts
console.log(style('Highlighted fruits: ~underline{Apple}, cat, ~underline{Banana}'))
```
![](assets/underline.png)

Strikethrough text

```ts
console.log(style('~strike.red{Deleted file.ext}'))
```
![](assets/strikethrough.png)

Custom functions

```ts
function warning(str) {
  return style(`⚠️  ~bold.black.bgYellow{${str}}`);
}

console.log(warning(' CAUTION '))
```
![](assets/caution.png)


## Style names

- #### Foreground colors
  - blue
  - red
  - green
  - orange
  - navy
  - aqua
  - teal
  - purple
  - fuchsia
  - maroon
  - yellow
  - olive
  - lime
  - black
  - gray
  - silver
  - white


- #### Background colors
  - bgBlue
  - bgRed
  - bgGreen
  - bgOrange
  - bgNavy
  - bgAqua
  - bgTeal
  - bgPurple
  - bgFuchsia
  - bgMaroon
  - bgYellow
  - bgOlive
  - bgLime
  - bgBlack
  - bgGray
  - bgSilver
  - bgWhite

- rgb(red, green, blue)

- bgRgb(red, green, blue)

- #### Modifiers
  - bold  
  - dim  
  - italic  
  - underline  
  - inverse  
  - strike  

## References

https://en.wikipedia.org/wiki/ANSI_escape_code


## License

Copyright (c) 2021, Thanga Ganapathy ([MIT License](./LICENSE)).

---
_Source: https://npm.io/package/@open-tech-world/es-cli-styles · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
