Giter Site home page Giter Site logo

chalk's Introduction

Chalk





Expressive styling on terminal string.

Highlights

  • Expressive API
  • 256/TrueColor support
  • Nest styles
  • Auto downgrading to terminal supported color
  • No extensions on String
  • rgb & hsl & hsv & hex
  • Built-in 100+ beautiful colors

Usage

Chalk's API is very similar to chalk -- one of the most popular packages on npm.

print(chalk.cyan.on("cyan"))  // `ck` is an alias to `chalk`

// chainable
print(ck.red.bgBlue.italic.underline.on("red bgBlue italic underline"))

// combine terminal string and string
print(ck.red.on("ERROR") + " something went wrong. " + ck.green.on("but no worry! I will..."))

// rgb & hsl & hsv & hex support
print(ck.fg(.rgb(0, 92, 197)).bg(.hex(0xFA4B8B)).on("meow"))

// custom foreground color and background color with 100+ handpicked colors
print(ck.fg(.darkMagenta).bg(.lightGoldenRodYellow).bold.on("hi"))

// nest
print(ck.magenta.underline.on("begin" + ck.red.bold.on("important") + "end"))
print(ck.magenta.underline.on("begin", ck.red.bold.on("important"), "end"))

Styles

Modifiers

reset
bold
faint              // aka dim, not widely supported.
italic
underline
blink
reverse
conceal            // aka hidden, not widely supported.
crossedOut         // aka strikethrough, not widely supported.

Colors

The powerful color system is built on Rainbow.

Ansi16

// with `bg` prefix will set background color

black
red
green
yellow
blue
magenta
cyan
white

blackBright
redBright
greenBright
yellowBright
blueBright
magentaBright
cyanBright
whiteBright

256/TrueColoe

ck.fg(.rgb(0, 100, 200))
ck.fg(.hsl(300, 50, 50))
ck.fg(.hsv(300, 50, 50))
ck.bg(.hex(0x123456))
ck.bg(.hex("#123456")
ck.bg(.hex("#abc")

Built-in 100+ beautiful colors

let color = Color.Material.red50
let color = Color.Material.purple500
let color = Color.CSS.navy
let color = Color.CSS.tomato

ck.fg(color)
ck.bg(color)
//...

Install

dependencies: [
    .package(url: "https://github.com/luoxiu/Chalk", from: "0.2.0")
]
pod 'Chalk', '~> 0.2.0'

Acknowledge

Inspired by the awesome javascript library chalk.

Related

  • Rainbow - 🌈 Color conversion and manipulation library for Swift with no dependence on UIKit/AppKit.

Contribute

If you find a bug, open an issue, if you want to add new features, feel free to submit a pull request. Any contributing is welcome at all times!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.