styl3
terminal styling
Last updated a year ago by tool3 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install styl3 
SYNC missed versions from official npm registry.

styl3 3.2.0

themeable cli coloring

What's New

✅ 20 built-in themes!
✅ Formatting decorators!
✅ Supports custom colors and custom themes!
✅ Supports hex, rgb, or ansi color codes
✅ Color conversion utils such as rgb/hex/ansi
✅ Easy and flexible api ✅ New write and timestamp options!

usage

styl3 can provide color names as functions for coloring output and decorators for adding specific formatting for a given string.
for example:

import style from "styl3";

const styled = style();

const output = [
  "@*Never* gonna give you !up!@",
  "@Never gonna %let you down%@",
  "@$Never$ gonna run around and *desert* you@"
];

const style = require("styl3");
const s = style();

console.log(s.red`this will be a default red`);
// access a theme specifically
console.log(s.pastel.green`this will be a pastel green`);

const ss = style({ theme: "pastel" });
// now `ss.green` points to the pastel green

console.log(ss.green`also a pastel green`);

// supports custom hex
console.log(ss.hex("#de5285")`this will be a slick pink`);
// and rgb
console.log(ss.rgb(15, 106, 251)`this will be a rich blue`);

decorators

decorators are characters used to wrap a word and give it decorating features, such as bold, italic, underline, strikeout, inverted and italic.

more than one decorator can be applied to a word

map

{
  bold: '*',
  underline: '!',
  dim: '~',
  hidden: '#',
  invert: '@',
  blink: '^',
  italic: '%',
  strikeout: '$'
}

usage

const style = require("styl3");
const s = style({ theme: "pastel" });

// use decorators for bold, underline etc...
console.log(s.red`lush red *BOLD* @INVERTED@`);
// double decoratros
console.log(s.cyan`this is !*bolderlined!*! get it? bold and underlined...😏`);
console.log(s.green`viva la %italic%`);
console.log(s.pink`address: ~you@somewhere.earth~`);

you can also provide your own custom decorators map:

const style = require("styl3");
const s = style({ theme: "pastel", decorators: { bold: "_" } });

// use custom decorators
console.log(s.red`this will now be _BOLD_`);

you can also provide your own color theme:

import style from `styl3`;

const custom = style({
  theme: "custom",
  colors: {
    custom: {
      red: "#750404",
      green: "#1b7504",
      yellow: "#929605",
      blue: "#041382",
      purple: "#620182",
      cyan: "#027678",
      pink: "#a3039b",
      orange: "#b37202"
    }
  }
});

// use custom colors
console.log(s.green`this will be with #1b7504 color`);

themes

15 unique built-in themes to get you started on easy cli styling

Theme Screenshot
autumn
beach
champagne
crayons
lush
mint
nature
neon
pastel
pinkish
pool
rainbow
rufus
sport
spring
summer
sunset
vintage
standard
default

options

styl3 3.2.0 introduces 2 new options for quality of life.

write

using this option set to true - styl3 will perform the console.log for you.

timestamp

using this option styl3 will add a timestamp to each print using the time it is printed.
primarily aimed at logging use-cases.

example

import style from `styl3`

const styled = style({
  write: true,
  timestamp: {
    format: {  dateStyle: 'short', timeStyle: 'short' },
    color: 'blue'
  }
});

const a = styled.blue`this will be logged out - no need to wrap in console.log`
// a still has the string formatted just in case you need it :)

styled.red`log is red but timestamp is blue`
// [9/2/25, 4:49 PM] log is red but timestamp is blue

Current Tags

  • 3.2.0                                ...           latest (a year ago)

21 Versions

  • 3.2.0                                ...           a year ago
  • 3.1.3                                ...           a year ago
  • 3.1.2                                ...           a year ago
  • 3.1.1                                ...           2 years ago
  • 3.1.0                                ...           2 years ago
  • 3.0.0                                ...           3 years ago
  • 2.4.0                                ...           3 years ago
  • 2.3.0                                ...           3 years ago
  • 2.2.0                                ...           3 years ago
  • 2.1.0                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
  • 1.4.0                                ...           5 years ago
  • 1.3.0                                ...           5 years ago
  • 1.2.4                                ...           5 years ago
  • 1.2.3                                ...           5 years ago
  • 1.2.2                                ...           5 years ago
  • 1.2.1                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Total 79
Today 0
This Week 0
This Month 24
Last Day 0
Last Week 0
Last Month 55
Dependencies (0)
None
Dev Dependencies (9)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE