🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@kabeep/palette

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kabeep/palette

A Node.js library for terminal text colour & style in FP.

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

Palette

🎨 A Node.js library for terminal text colour & style in FP.

NodeJS License NPM Codecov BundlePhobia CircleCI

English | 简体中文

📖 Introduction

chalk offers a user-friendly, chainable API. In spite of the excellent work done by @sindresorhus to reduce the size of the packaging as much as possible. But my view is that the key issue is not "Why not switch to a smaller coloring package?". Here’s why:

  • No tree-shaking support, and no FP such as pipe/compose.
  • You will still need to create the full chalk using the factory function if you only need to colour the red failure and green success messages.
  • In lightweight scenarios, static ANSI strings are much more cost-effective.

So I created this package. It supports ANSI 16 colours, 256 colours and 16 million true colours like chalk. Compared to other lightweight alternatives, it goes beyond basic ANSI keywords and also supports Hex Triplet, RGB Color Model, and CSS Keywords.

But this does not mean it compromises on size or performance. On the contrary, it performs excellently in Benchmark Reports. Of course, all the coloring packages are more than fast enough, I am just saying @kabeep/palette is a good choice for people who value size and performance.

See documentation.

📦 Installation

npm install @kabeep/palette --save
yarn add @kabeep/palette
pnpm add @kabeep/palette

⚙️ Usage

CommonJS

const pipe = require('lodash.flow');
const { bgRgb, hex, keyword, yellowBright } = require('@kabeep/palette');

const padding = (text: string) => ` ${text} `;
const palette = pipe(keyword('gold'), padding, bgRgb(255, 0, 0));

console.log(palette('Error'), yellowBright('Warning'), hex('#ff0000')('Message'));

ESModule

import pipe from 'lodash.flow';
import { bgRgb, hex, keyword, yellowBright } from '@kabeep/palette';

const padding = (text: string) => ` ${text} `;
const palette = pipe(keyword('gold'), padding, bgRgb(255, 0, 0));

console.log(palette('Error'), yellowBright('Warning'), hex('#ff0000')('Message'));

🌈 Styles

Modifiers

  • reset - Reset the current style.
  • bold - Make the text bold.
  • dim - Make the text have lower opacity.
  • italic - Make the text italic. (Not widely supported)
  • underline - Put a horizontal line above the text. (Not widely supported)
  • overline - Put a horizontal line below the text. (Not widely supported)
  • inverse- Invert background and foreground colors.
  • hidden - Print the text but make it invisible.
  • strikethrough - Put a horizontal line through the center of the text. (Not widely supported)

Foreground Colors

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • gray
  • redBright
  • greenBright
  • yellowBright
  • blueBright
  • magentaBright
  • cyanBright
  • whiteBright

Background Colors

  • bgBlack
  • bgRed
  • bgGreen
  • bgYellow
  • bgBlue
  • bgMagenta
  • bgCyan
  • bgWhite
  • bgGray
  • bgRedBright
  • bgGreenBright
  • bgYellowBright
  • bgBlueBright
  • bgMagentaBright
  • bgCyanBright
  • bgWhiteBright

Hex Triplet

  • hex - (three-digit) #fff, ...
  • hex - (six-digit) #ffffff, ...
  • hex - (without hashtag) fff, ffffff, ...

RGB Color Model

  • rgb - (255, 255, 255), ...

CSS Color Keywords

See the full list at W3C Wiki.

  • keyword - azure, gold, indigo, ...

💐 Credits

  • palette-cli - A Node.js Library to make your terminal input colorful.

🤝 Contribution

Contributions via Pull Requests or Issues are welcome.

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

Keywords

color

FAQs

Package last updated on 22 Oct 2025

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