Skip to content

Commit 1d73b21

Browse files
committed
Improve readme
1 parent 6f4d6b3 commit 1d73b21

File tree

1 file changed

+52
-41
lines changed

1 file changed

+52
-41
lines changed

readme.md

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<h1 align="center">
22
<br>
33
<br>
4-
<img width="360" src="https://cdn.rawgit.com/chalk/chalk/19935d6484811c5e468817f846b7b3d417d7bf4a/logo.svg" alt="chalk">
4+
<img width="320" src="https://cdn.rawgit.com/chalk/chalk/19935d6484811c5e468817f846b7b3d417d7bf4a/logo.svg" alt="chalk">
55
<br>
66
<br>
77
<br>
@@ -18,22 +18,23 @@
1818
![](https://github.com/chalk/ansi-styles/raw/master/screenshot.png)
1919

2020

21-
## Why
21+
## Highlights
2222

23-
- Highly performant
24-
- Doesn't extend `String.prototype`
2523
- Expressive API
24+
- Highly performant
2625
- Ability to nest styles
27-
- Clean and focused
26+
- [256/Truecolor color support](#256-and-truecolor-color-support)
2827
- Auto-detects color support
28+
- Doesn't extend `String.prototype`
29+
- Clean and focused
2930
- Actively maintained
30-
- [Used by ~16,000 modules](https://www.npmjs.com/browse/depended/chalk) as of May 31st, 2017
31+
- [Used by ~17,000 packages](https://www.npmjs.com/browse/depended/chalk) as of June 20th, 2017
3132

3233

3334
## Install
3435

3536
```console
36-
$ npm install --save chalk
37+
$ npm install chalk
3738
```
3839

3940

@@ -51,19 +52,19 @@ Chalk comes with an easy to use composable API where you just chain and nest the
5152
const chalk = require('chalk');
5253
const log = console.log;
5354

54-
// combine styled and normal strings
55+
// Combine styled and normal strings
5556
log(chalk.blue('Hello') + 'World' + chalk.red('!'));
5657

57-
// compose multiple styles using the chainable API
58+
// Compose multiple styles using the chainable API
5859
log(chalk.blue.bgRed.bold('Hello world!'));
5960

60-
// pass in multiple arguments
61+
// Pass in multiple arguments
6162
log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
6263

63-
// nest styles
64+
// Nest styles
6465
log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
6566

66-
// nest styles of the same type even (color, underline, background)
67+
// Nest styles of the same type even (color, underline, background)
6768
log(chalk.green(
6869
'I am a green line ' +
6970
chalk.blue.underline.bold('with a blue substring') +
@@ -83,7 +84,7 @@ log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
8384
log(chalk.hex('#DEADED').bold('Bold gray!'));
8485
```
8586

86-
Easily define your own themes.
87+
Easily define your own themes:
8788

8889
```js
8990
const chalk = require('chalk');
@@ -95,7 +96,7 @@ console.log(error('Error!'));
9596
console.log(warning('Warning!'));
9697
```
9798

98-
Take advantage of console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data).
99+
Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
99100

100101
```js
101102
const name = 'Sindre';
@@ -110,13 +111,13 @@ console.log(chalk.green('Hello %s'), name);
110111

111112
Example: `chalk.red.bold.underline('Hello', 'world');`
112113

113-
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `Chalk.red.yellow.green` is equivalent to `Chalk.green`.
114+
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
114115

115116
Multiple arguments will be separated by space.
116117

117118
### chalk.level
118119

119-
Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all chalk consumers.
120+
Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.
120121

121122
If you need to change this in a reusable module create a new instance:
122123

@@ -129,13 +130,15 @@ Levels are as follows:
129130
0. All colors disabled
130131
1. Basic color support (16 colors)
131132
2. 256 color support
132-
3. RGB/Truecolor support (16 million colors)
133+
3. Truecolor support (16 million colors)
133134

134135
### chalk.supportsColor
135136

136137
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
137138

138-
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, add an environment variable `FORCE_COLOR` with any value to force color. Trumps `--no-color`.
139+
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, add the environment variable `FORCE_COLOR=1` to forcefully enable color or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
140+
141+
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
139142

140143

141144
## Styles
@@ -145,23 +148,31 @@ Can be overridden by the user with the flags `--color` and `--no-color`. For sit
145148
- `reset`
146149
- `bold`
147150
- `dim`
148-
- `italic` *(not widely supported)*
151+
- `italic` *(Not widely supported)*
149152
- `underline`
150153
- `inverse`
151154
- `hidden`
152-
- `strikethrough` *(not widely supported)*
155+
- `strikethrough` *(Not widely supported)*
153156

154157
### Colors
155158

156159
- `black`
157160
- `red`
158161
- `green`
159162
- `yellow`
160-
- `blue` *(on Windows the bright version is used since normal blue is illegible)*
163+
- `blue` *(On Windows the bright version is used since normal blue is illegible)*
161164
- `magenta`
162165
- `cyan`
163166
- `white`
164167
- `gray`
168+
- `blackBright`
169+
- `redBright`
170+
- `greenBright`
171+
- `yellowBright`
172+
- `blueBright`
173+
- `magentaBright`
174+
- `cyanBright`
175+
- `whiteBright`
165176

166177
### Background colors
167178

@@ -173,15 +184,23 @@ Can be overridden by the user with the flags `--color` and `--no-color`. For sit
173184
- `bgMagenta`
174185
- `bgCyan`
175186
- `bgWhite`
187+
- `bgBlackBright`
188+
- `bgRedBright`
189+
- `bgGreenBright`
190+
- `bgYellowBright`
191+
- `bgBlueBright`
192+
- `bgMagentaBright`
193+
- `bgCyanBright`
194+
- `bgWhiteBright`
176195

177196

178-
## 256/16 million (Truecolor) color support
197+
## 256 and Truecolor color support
179198

180-
Chalk supports 256 colors and, when manually specified, [Truecolor (16 million colors)](https://gist.github.com/XVilka/8346728) on all supported terminal emulators.
199+
Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
181200

182-
Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying {level: n} as a chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
201+
Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
183202

184-
Some examples:
203+
Examples:
185204

186205
- `chalk.hex('#DEADED').underline('Hello, world!')`
187206
- `chalk.keyword('orange')('Some orange text')`
@@ -193,24 +212,16 @@ Background versions of these models are prefixed with `bg` and the first level o
193212
- `chalk.bgKeyword('orange')('Some orange text')`
194213
- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
195214

196-
As of this writing, these are the supported color models that are exposed in Chalk:
197-
198-
- `rgb` - e.g. `chalk.rgb(255, 136, 0).bold('Orange!')`
199-
- `hex` - e.g. `chalk.hex('#ff8800').bold('Orange!')`
200-
- `keyword` (CSS keywords) - e.g. `chalk.keyword('orange').bold('Orange!')`
201-
- `hsl` - e.g. `chalk.hsl(32, 100, 50).bold('Orange!')`
202-
- `hsv`
203-
- `hwb`
204-
- `cmyk`
205-
- `xyz`
206-
- `lab`
207-
- `lch`
215+
The following color models can be used:
216+
217+
- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
218+
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
219+
- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
220+
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
221+
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 1, 1).bold('Orange!')`
222+
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hsl(32, 0, 50).bold('Orange!')`
208223
- `ansi16`
209224
- `ansi256`
210-
- `hcg`
211-
- `apple` (see [qix-/color-convert#30](https://github.com/Qix-/color-convert/issues/30))
212-
213-
For a complete list of color models, see [`color-convert`'s list of conversions](https://github.com/Qix-/color-convert/blob/master/conversions.js).
214225

215226

216227
## Windows

0 commit comments

Comments
 (0)