# chalk-pipe

> Create chalk style schemes with simpler style strings

Latest version **6.2.0** (published 2024-10-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install chalk-pipe
pnpm add chalk-pipe
yarn add chalk-pipe
bun add chalk-pipe
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 6.2.0 |
| Published | 2024-10-07 |
| First published | 2017-08-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | ^12.17.0 \|\| ^14.13 \|\| >=16.0.0 |
| Dependencies | 1 |
| Unpacked size | 19.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 37 |
| Author | LitoMore |
| Maintainers | litomore |

## Links

- npm: https://www.npmjs.com/package/chalk-pipe
- Repository: https://github.com/LitoMore/chalk-pipe
- Homepage: https://github.com/LitoMore/chalk-pipe#readme
- Issues: https://github.com/LitoMore/chalk-pipe/issues
- npm.io page: https://npm.io/package/chalk-pipe

## Dependencies (1)

- [chalk](https://npm.io/package/chalk.md) ^5.3.0

## Recent versions

- 6.2.0 (latest) — 2024-10-07
- 6.1.0 — 2024-08-17
- 6.0.0 — 2022-11-15
- 5.1.2 — 2022-10-03
- 5.1.1 — 2021-04-23
- 5.1.0 — 2021-04-23
- 5.0.0 — 2021-01-25
- 4.0.0 — 2020-04-29
- 3.0.0 — 2019-11-09
- 2.0.0 — 2018-09-06
- 1.3.0 — 2018-08-13
- 1.2.0 — 2018-01-19
- 1.1.0 — 2017-09-08
- 1.0.0 — 2017-08-23

## README

# chalk-pipe

[![](https://github.com/LitoMore/chalk-pipe/workflows/Node/badge.svg)](https://github.com/LitoMore/chalk-pipe/actions)
[![](https://img.shields.io/npm/v/chalk-pipe.svg)](https://www.npmjs.com/package/chalk-pipe)
[![](https://img.shields.io/npm/l/chalk-pipe.svg)](https://github.com/LitoMore/chalk-pipe/blob/main/LICENSE)
[![](https://shields.io/badge/code_style-5ed9c7?logo=xo&labelColor=gray)](https://github.com/xojs/xo)

Create chalk style schemes with simpler style strings

![](https://raw.githubusercontent.com/LitoMore/chalk-pipe/main/screenshot.png)

## Install

```sh
npm install chalk-pipe
```

## Usage

```js
import chalkPipe from 'chalk-pipe';

console.log(chalkPipe('blue.bold')('Hello world!'));
```

Use dot `.` to separeate multiple styles:

```js
const link = chalkPipe('blue.underline');
const error = chalkPipe('bgRed.#cccccc');
const warning = chalkPipe('orange.bold');

console.log(link('Link!'));
console.log(error('Error!'));
console.log(warning('Warning!'));
```

`chalkPipe` is also `chalk`:

```js
const blue = chalkPipe('blue');
const link = blue.underline;

console.log(link('Link!'));
```

### Use custom chalk

```js
import chalkPipe, {chalk, Chalk} from 'chalk-pipe';

const customChalk = new Chalk({level: 1});

console.log(chalkPipe('underline', chalk.blue)('Link!'));
console.log(chalkPipe('underline', customChalk.blue)('Link!'));
```

## Built-in Chalk

All Chalk exported functions, variables, and declarations are exposed for convenience.

This can be useful if you want to use `chalk` directly.

```js
import {chalk, Chalk} from 'chalk-pipe';

const customChalk = new Chalk({level: 0});

console.log(chalk.blue('Hello'))
console.log(customChalk.green('World'));
```

## API

### chalkPipe(styles)(text)

Example:

 ```js
 chalkPipe('blue.underline')('Link!');
 ```

### chalkPipe(styles, chalk)(text)

Example:

```js
import {Chalk} from 'chalk-pipe';

const chalk = new Chalk({level: 1});

chalkPipe('underline', chalk.blue)('Link!');
```

### keywordNames

All supported keyword names are exposed as array of strings for convenience.

```js
import {keywordNames} from 'chalk-pipe';

console.log(keywordNames.includes('pink'));
//=> true
```

## Supported styles

- [Modifiers](https://github.com/chalk/chalk#modifiers)
- [Colors](https://github.com/chalk/chalk#colors)
- [Background colors](https://github.com/chalk/chalk#background-colors)
- [Hex triplet](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet)
- [CSS keywords](https://www.w3.org/wiki/CSS/Properties/color/keywords)

## Related

- [chalk-pipe-cli](https://github.com/LitoMore/chalk-pipe-cli) - CLI for this module
- [ink-color-pipe](https://github.com/LitoMore/ink-color-pipe) - Ink component for this module
- [inquirer-chalk-pipe](https://github.com/LitoMore/inquirer-chalk-pipe) - A inquirer plugin for input chalk-pipe style strings
- [chalk](https://github.com/chalk/chalk) - Output colored text to terminal

## License

MIT © [LitoMore](https://github.com/LitoMore)

---
_Source: https://npm.io/package/chalk-pipe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
