Skip to content

v4.2.0

Latest

Choose a tag to compare

@webdiscus webdiscus released this 28 Sep 19:40
· 14 commits to master since this release
21ae59d

Feature

Added support named truecolors via ansis.extend() for both foreground and background.

Foreground methods are created from the provided color names, and matching background methods bg* are generated automatically.

output

Open in StackBlitz

Example:

import ansis from 'ansis';
import colorNames from 'css-color-names';

const color = ansis.extend(colorNames);

console.log(color.orange('Orange foreground'));
console.log(color.bgOrange('Orange background')); // auto-generated from "orange"

Note

The css-color-names (~6 kB) package exports CSS color names with their hex values.

This release removes the last barrier for projects migrating from Chalk v4 that used named truecolors:

- chalk.keyword('orange')('text');
+ color.orange('text');

- chalk.bgKeyword('orange')('text');
+ color.bgOrange('text');

Ansis provides this feature with a simpler, more intuitive API.

Important

Fallback for named truecolors

Ansis automatically interpolates named truecolors to the highest available color level supported by the current environment.
So you can safely use named truecolors anywhere without worrying about compatibility.