New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

chalk-dom

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chalk-dom

Chalk for the browser

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

Chalk-dom

chalk for the browser


Just like chalk but right in your browser. It uses HTMElement elements (b,s,i,span) and a little inline-css.


GitHub Workflow Status npm GitHub release (latest SemVer) GitHub

Features

  • Expressive API
  • Highly performant
  • Ability to nest styles
  • Customizable
  • Doesn't extend String.prototype
  • Clean and focused
  • Actively maintained

Install

$ npm install chalk-dom

Usage

HTML

<div id='console'></div>

JavaScript

import chalk from 'chalk-dom';

const consoleBox = document.getElementById('console');

function log(...data) {
    consoleBox.innerHTML += `<div>${data.join(' ')}</div>`;
}

log(chalk.blue('Hello World!'));

Demo

To run the demo, clone this repo and simply open the index.html file in your browser.

API

The one difference with inken is styles can be chained with chalk-dom.

import chalk from 'chalk-dom';

...

log(chalk.bgBlack.yellow.italic('Hello, World!'));

Styles

Modifiers

  • bold - Make the text bold.
  • dim - Make the text have lower opacity (sets css opacity to 0.5).
  • italic - Make the text italic.
  • underline - Underline the text.
  • strikethrough - Put a horizontal line through the center of the text.
  • inverse - Invert the background and foreground colors.

User defined

  • fg - Set a custom foreground color (text color)
  • bg - Set a custom background color

Colors

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • gray

Background colors

  • bgBlack
  • bgRed
  • bgGreen
  • bgYellow
  • bgBlue
  • bgMagenta
  • bgCyan
  • bgWhite
  • bgGray
  • Inken - terminal-like string styling for the browser
  • xterminal - build web-based cli interfaces

LICENSE

Released under the MIT License

Keywords

chalk

FAQs

Package last updated on 12 Jul 2023

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