Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ortense/consolestylejs
A lightweight package that allows you to style your terminal output with ease in your js/ts projects
https://github.com/ortense/consolestylejs
ansi-escape-codes bun cli color command-line commandline console deno dependency-free javascript nodejs terminal typescript
Last synced: 27 days ago
JSON representation
A lightweight package that allows you to style your terminal output with ease in your js/ts projects
- Host: GitHub
- URL: https://github.com/ortense/consolestylejs
- Owner: ortense
- License: mit
- Created: 2024-03-09T17:19:58.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-17T03:41:03.000Z (10 months ago)
- Last Synced: 2024-12-14T19:38:18.675Z (about 1 month ago)
- Topics: ansi-escape-codes, bun, cli, color, command-line, commandline, console, deno, dependency-free, javascript, nodejs, terminal, typescript
- Language: TypeScript
- Homepage: https://ortense.github.io/consolestylejs/
- Size: 220 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @ortense/consolestyle
![consolestyle demo in vscode terminal](https://raw.githubusercontent.com/ortense/consolestylejs/main/media/banner.png)
[![Coverage Status](https://coveralls.io/repos/github/ortense/consolestylejs/badge.svg?branch=main)](https://coveralls.io/github/ortense/consolestylejs?branch=main) ![npm bundle size](https://img.shields.io/bundlephobia/min/%40ortense%2Fconsolestyle) [![GitHub License](https://img.shields.io/github/license/mashape/apistatus?branch=main&label=License&logo=GitHub&logoColor=ffffff&labelColor=282828&color=informational&style=flat)](https://github.com/ortense/consolestylejs/blob/main/LICENSE)
A lightweight package weighing just 18.8 kB that allows you to style your console output with ease, adding colors, backgrounds, and various text styles to enhance your command-line experience.
## Install
Pick your favorite package manager.
```sh
npm install @ortense/consolestyle # npm
yarn add @ortense/consolestyle # yarn
pnpm add @ortense/consolestyle # pnpm
bun add @ortense/consolestyle # bun
deno add @ortense/consolestyle # deno from jsr.io
```## Usage
You can use the fluent api of `style` function.
```ts
import {style} from '@ortense/consolestyle'const message = style('Hello there! 👋').cyan().italic()
.emptyLine()
.newLine('Are u tired of boring console outputs?').inverse()
.emptyLine()
.newLine('✨ Now u can easily create fun console messages! 🦄').magenta().bold()console.log(message.toString())
```Alternatively, you can choose specific functions to apply styles to your console output.
```ts
import {green, underline} from '@ortense/consolestyle'const message = underline(green('Simplicity is sophistication 🍃'))
console.log(message)
```
More details in the [complete documentation](https://ortense.github.io/consolestylejs/).## Key Features
- Easily style your console output with a fluent API.
- Apply a wide range of text colors, backgrounds, and styles.
- Enhance your command-line interface with vibrant and visually appealing messages.### Available styles
- `red()`: Apply red text color.
- `green()`: Apply green text color.
- `yellow()`: Apply yellow text color.
- `blue()`: Apply blue text color.
- `magenta()`: Apply magenta text color.
- `cyan()`: Apply cyan text color.
- `bgRed()`: Apply red background color.
- `bgGreen()`: Apply green background color.
- `bgYellow()`: Apply yellow background color.
- `bgBlue()`: Apply blue background color.
- `bgMagenta()`: Apply magenta background color.
- `bgCyan()`: Apply cyan background color.
- `inverse()`: Apply inverted colors
- `bold()`: Apply bold text style.
- `dim()`: Apply dim text style.
- `italic()`: Apply italic text style.
- `underline()`: Apply underline text style.
- `strike()`: Apply strike-through text style.## License
This package is licensed under the MIT License. See the LICENSE file for details.