Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chalk.js

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chalk.js

[Chalk](//github.com/chalk/chalk) for the browser. Useful with [xterm.js](//github.com/xtermjs/xterm.js).

  • 0.0.5
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

chalk.js

Chalk for the browser. Useful with xterm.js.

Demo

Live demo

image

To see the demo locally, run yarn && yarn start.

Using chalk.js

<script src="https://unpkg.com/chalk.js@latest/chalk.js"></script>

Then use Chalk from anywhere in your code:

console.log(Chalk.red("foo"))

To convert to HTML, you can call AnsiHTML and pass in a chalk string:

document.body.innerHTML = AnsiHTML(Chalk.red("foo"));

Example

See the source code of the live demo:

<html>
  <body>
    <script src="https://unpkg.com/chalk.js@latest/chalk.js"></script>

    <!-- How to manually create HTML elements from Chalk strings -->
    <div id="code">
    </div>
    <script>
      var html = AnsiHTML(Chalk.magenta.bold.italic.underline("Hello from HTML!"));
      document.getElementById("code").innerHTML = html;
    </script>

    <!-- How to use Chalk with xterm.js -->
    <script src="https://unpkg.com/xterm@latest/dist/xterm.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/xterm@latest/dist/xterm.css" />

    <div id="terminal">
    </div>
    <script>
      var term = new Terminal();
      term.open(document.getElementById('terminal'));
      term.write(`${Chalk.red("Hello")} from ${Chalk.bold.underline.bgCyanBright.black('xterm.js')} !`);
    </script>
  </body>
</html>

FAQs

Package last updated on 19 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc