ansis v3.2.0
Colorize terminal with ANSI colors & styles, smaller and faster alternative to Chalk.
Usage example
import ansis, { red, green, black, ansi256, hex } from 'ansis';
ansis.cyan('path/to/file')
green('Succeful!')
red`Error!`
black.bgYellow`Warning!`
ansi256(214)`Orange`
hex('#E0115F').bold.underline('Hello TrueColor!')
š Install and Quick Start\ š Read full docs on GitHub
š Compare & Benchmark
See the features comparison and benchmarks of most popular terminal colors libraries:\
ansis
chalk
kleur
kolorist
colors.js
colorette
picocolors
ansi-colors
cli-color
colors-cli
.
š” Highlights
- Supports ESM, CommonJS, TypeScript, Bun, Deno, Next.JS
- Standard API compatible with Chalk
- Default and named import
import ansis, { red, green, bold, underline } from 'ansis'
- Chained syntax
red.bold.underline('text')
- Nested template strings
red`RED text ${green`GREEN text`} RED text`
- Base ANSI styles
dim
bold
italic
underline
strikethrough
- Base ANSI 16 colors
red`Error!`
redBright`Error!`
bgRed`Error!`
bgRedBright`Error!`
- ANSI 256 colors
fg(56)`violet`
bg(208)`orange`
- TrueColor (RGB, HEX)
rgb(224, 17, 95)`Ruby`
,hex('#96C')`Amethyst`
- Fallback to supported color space: TrueColor ā 256 colors ā 16 colors ā no colors
- ANSI codes as
open
andclose
properties`Hello ${red.open}World${red.close}!`
- Strip ANSI codes method
ansis.strip()
- Correct style break at the
end of line
when used\n
in string - Detect color support using
ansis.isSupported()
method - Supports CLI
NO_COLOR
FORCE_COLOR
--no-color
--color
- Doesn't extend
String.prototype
- Zero dependencies
License
7 days ago
16 days ago
23 days ago
23 days ago
22 days ago
30 days ago
1 month ago
3 months ago
3 months ago
3 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago