source: trip-planner-front/node_modules/colorette/README.md@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.8 KB
Line 
1# Colorette
2
3> Easily set the text color and style in the terminal.
4
5- No wonky prototype method-chain API.
6- Automatic color support detection.
7- Up to [2x faster](#benchmarks) than alternatives.
8- [`NO_COLOR`](https://no-color.org) friendly. 👌
9
10Here's the first example to get you started.
11
12```js
13import { blue, bold, underline } from "colorette"
14
15console.log(
16 blue("I'm blue"),
17 bold(blue("da ba dee")),
18 underline(bold(blue("da ba daa")))
19)
20```
21
22Here's an example using [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals).
23
24```js
25console.log(`
26 There's a ${underline(blue("house"))},
27 With a ${bold(blue("window"))},
28 And a ${blue("corvette")}
29 And everything is blue
30`)
31```
32
33Of course, you can nest styles without breaking existing color sequences.
34
35```js
36console.log(bold(`I'm ${blue(`da ba ${underline("dee")} da ba`)} daa`))
37```
38
39Feeling adventurous? Try the [pipeline operator](https://github.com/tc39/proposal-pipeline-operator).
40
41```js
42console.log("Da ba dee da ba daa" |> blue |> bold)
43```
44
45## Installation
46
47```console
48npm install colorette
49```
50
51## API
52
53### `<style>(string)`
54
55See [supported styles](#supported-styles).
56
57```js
58import { blue } from "colorette"
59
60blue("I'm blue") //=> \x1b[34mI'm blue\x1b[39m
61```
62
63### `options.enabled`
64
65Colorette automatically detects if your terminal can display color, but you can toggle color as needed.
66
67```js
68import { options } from "colorette"
69
70options.enabled = false
71```
72
73You can also force the use of color globally by setting `FORCE_COLOR=` or `NO_COLOR=` from the CLI.
74
75```console
76$ FORCE_COLOR= node example.js >log
77$ NO_COLOR= node example.js
78```
79
80## Supported styles
81
82| Colors | Background Colors | Bright Colors | Bright Background Colors | Modifiers |
83| ------- | ----------------- | ------------- | ------------------------ | ----------------- |
84| black | bgBlack | blackBright | bgBlackBright | dim |
85| red | bgRed | redBright | bgRedBright | **bold** |
86| green | bgGreen | greenBright | bgGreenBright | hidden |
87| yellow | bgYellow | yellowBright | bgYellowBright | _italic_ |
88| blue | bgBlue | blueBright | bgBlueBright | <u>underline</u> |
89| magenta | bgMagenta | magentaBright | bgMagentaBright | ~~strikethrough~~ |
90| cyan | bgCyan | cyanBright | bgCyanBright | reset |
91| white | bgWhite | whiteBright | bgWhiteBright | |
92| gray | | | | |
93
94## Benchmarks
95
96```console
97npm --prefix bench start
98```
99
100## License
101
102[MIT](LICENSE.md)
Note: See TracBrowser for help on using the repository browser.