An open API service indexing awesome lists of open source software.

https://github.com/nehu3n/litecolor

🎨 An ultra-tiny and elegant console style library compatible with any environment.
https://github.com/nehu3n/litecolor

agnostic chalk colors console elegant styles tiny

Last synced: about 1 month ago
JSON representation

🎨 An ultra-tiny and elegant console style library compatible with any environment.

Awesome Lists containing this project

README

          

# LiteColor

An ultra-tiny, elegant, and agnostic library for console styling, written in TypeScript.

```ts
import { style } from "litecolor";

const text = style("Hello world!")
.color("green")
.bold()
.toString();

console.log(text);
```

##### See more examples in the [examples folder](./examples).

---

## ✨ Features

- Ultra tiny (_0.9kb_) [![Minzipped size][bundlephobia-src]][bundlephobia-href]
- Elegant API
- Agnostic (Deno, Bun and NodeJS)
- Variety of styles and colors

---

## 🎀 Styles and colors

_A clarification:_ the `.toString()` method is required to convert a string after applying colors and styles.

#### Colors are applied with the `.color()` method.

```ts
const text = style("hello world").color("red").toString(); // 'red' color
```

And they are the following:

```ruby
# Colors:
black
red
green
yellow
blue
magenta
cyan
white
gray
grey

# More vivid colors:
brightBlack
brightRed
brightGreen
brightYellow
brightBlue
brightMagenta
brightCyan
brightWhite
brightGray
brightGrey
```

#### Each style has its own method.

```ts
const text = style("hello world").bold().toString(); // 'bold' style
```

And they are the following:

```ruby
# Styles:
reset
bold
dim
italic
underline
inverse
hidden
strikethrough
```

#### Background colors are applied with the `.bg()` method.

```ts
const text = style("hello world").bg("green").toString(); // 'green' background color
```

---

## 📄 License

This project is licensed under the [MIT License](./LICENSE).

---

[bundlephobia-src]: https://badgen.net/bundlephobia/minzip/litecolor
[bundlephobia-href]: https://bundlephobia.com/result?p=litecolor