You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles)
  2. > [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
  3. You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
  4. ![](screenshot.png)
  5. ## Install
  6. ```
  7. $ npm install --save ansi-styles
  8. ```
  9. ## Usage
  10. ```js
  11. var ansi = require('ansi-styles');
  12. console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
  13. ```
  14. ## API
  15. Each style has an `open` and `close` property.
  16. ## Styles
  17. ### Modifiers
  18. - `reset`
  19. - `bold`
  20. - `dim`
  21. - `italic` *(not widely supported)*
  22. - `underline`
  23. - `inverse`
  24. - `hidden`
  25. - `strikethrough` *(not widely supported)*
  26. ### Colors
  27. - `black`
  28. - `red`
  29. - `green`
  30. - `yellow`
  31. - `blue`
  32. - `magenta`
  33. - `cyan`
  34. - `white`
  35. - `gray`
  36. ### Background colors
  37. - `bgBlack`
  38. - `bgRed`
  39. - `bgGreen`
  40. - `bgYellow`
  41. - `bgBlue`
  42. - `bgMagenta`
  43. - `bgCyan`
  44. - `bgWhite`
  45. ## Advanced usage
  46. By default you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
  47. - `ansi.modifiers`
  48. - `ansi.colors`
  49. - `ansi.bgColors`
  50. ###### Example
  51. ```js
  52. console.log(ansi.colors.green.open);
  53. ```
  54. ## License
  55. MIT © [Sindre Sorhus](http://sindresorhus.com)