JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q39604F

Package Exports

  • bun-colors
  • bun-colors/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bun-colors) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

bun-colors

A simple utility to apply ANSI text styling and colors in terminal output using Bun.

[!IMPORTANT]
Bun runtime only — this utility depends on Bun's color API and does not support other JavaScript runtimes like Node.js or Deno.

Features

  • Supports foreground (textColor) and background (backgroundColor) colors.
  • Applies common ANSI text modifiers like bold, underline, italic, blink, etc.
  • Uses Bun’s color APIs to generate accurate ANSI sequences.
  • Falls back gracefully when ANSI colors are disabled.

Installation

bun add bun-colors

Usage

import { style } from "bun-colors";

const styledText = style("Hello, world!", {
  textColor: "cyan",
  backgroundColor: [0, 0, 0],
  style: ["bold", "underline"],
});

console.log(styledText);

API

style(text: string, opts: StyleOptions): string

Applies ANSI styling and returns the styled text.

  • text: The string to style.

  • opts:

    • textColor?: Bun.ColorInput — Foreground color (e.g. "red", [255, 0, 0], "#ff0000").
    • backgroundColor?: Bun.ColorInput — Background color.
    • style?: Modifiers[] — Array of text modifiers ("bold", "italic", "underline", etc.).

Supported Modifiers

  • faint
  • strikethrough
  • conceal
  • swapColors
  • doubleUnderline
  • framed
  • overlined
  • bold
  • dim
  • italic
  • underline
  • blink
  • inverse
  • hidden