Cross-platform Unicode symbols for CLI applications. The symbols module provides consistent Unicode characters that adapt automatically based on the operating system and terminal capabilities.
Symbols available on all platforms with consistent appearance.
const symbols: {
/** Ballot box with X (☒) */
ballotDisabled: "☒";
/** Ballot box unchecked (☐) */
ballotOff: "☐";
/** Ballot box checked (☑) */
ballotOn: "☑";
/** Bullet point (•) */
bullet: "•";
/** White bullet point (◦) */
bulletWhite: "◦";
/** Full block character (█) */
fullBlock: "█";
/** Heart symbol (❤) */
heart: "❤";
/** Identical to symbol (≡) */
identicalTo: "≡";
/** Horizontal line (─) */
line: "─";
/** Reference mark (※) */
mark: "※";
/** Middle dot (·) */
middot: "·";
/** Minus sign (-) */
minus: "-";
/** Multiplication sign (×) */
multiplication: "×";
/** Division sign (÷) */
obelus: "÷";
/** Pencil down right (✎) */
pencilDownRight: "✎";
/** Pencil right (✏) */
pencilRight: "✏";
/** Pencil up right (✐) */
pencilUpRight: "✐";
/** Percent sign (%) */
percent: "%";
/** Pilcrow sign 2 (❡) */
pilcrow2: "❡";
/** Pilcrow sign (¶) */
pilcrow: "¶";
/** Plus-minus sign (±) */
plusMinus: "±";
/** Question mark (?) */
question: "?";
/** Section sign (§) */
section: "§";
/** Empty star (☆) */
starsOff: "☆";
/** Filled star (★) */
starsOn: "★";
/** Up-down arrow (↕) */
upDownArrow: "↕";
};Symbols that vary based on operating system and terminal capabilities.
const symbols: {
/** Cross mark - undefined on Windows, "✘" on other platforms */
ballotCross?: "✘";
/** Check mark - "√" on Windows, "✔" on other platforms */
check: "√" | "✔";
/** Cross mark - "×" on Windows, "✖" on other platforms */
cross: "×" | "✖";
/** Large ellipsis - "..." on Windows, "⋯" on other platforms */
ellipsisLarge: "..." | "⋯";
/** Ellipsis - "..." on Windows, "…" on other platforms */
ellipsis: "..." | "…";
/** Info symbol - "i" on Windows, "ℹ" on other platforms */
info: "i" | "ℹ";
/** Full-width question mark - undefined on Windows, "?" on other platforms */
questionFull?: "?";
/** Small question mark - "?" on Windows, "﹖" on other platforms */
questionSmall: "?" | "﹖";
/** Pointer - ">" on Windows, "▸" on Linux, "❯" on other platforms */
pointer: ">" | "▸" | "❯";
/** Small pointer - "»" on Windows, "‣" on Linux, "›" on other platforms */
pointerSmall: "»" | "‣" | "›";
/** Radio button off - "( )" on Windows, "◯" on other platforms */
radioOff: "( )" | "◯";
/** Radio button on - "(*)" on Windows, "◉" on other platforms */
radioOn: "(*)" | "◉";
/** Warning sign - "‼" on Windows, "⚠" on other platforms */
warning: "‼" | "⚠";
};Access to platform-specific symbol sets for advanced use cases.
/**
* Access the common symbols shared across all platforms
* (Non-enumerable property)
*/
const symbols: {
common: Record<string, string>;
};
/**
* Access the Windows-specific symbol set
* (Non-enumerable property)
*/
const symbols: {
windows: Record<string, string>;
};
/**
* Access the non-Windows symbol set
* (Non-enumerable property)
*/
const symbols: {
other: Record<string, string>;
};Usage Examples:
const colors = require('ansi-colors');
// Basic symbol usage
console.log(`${colors.symbols.check} Task completed`);
console.log(`${colors.symbols.cross} Task failed`);
console.log(`${colors.symbols.warning} Warning message`);
// Interactive prompts
console.log(`${colors.symbols.pointer} Select an option:`);
console.log(` ${colors.symbols.radioOff} Option 1`);
console.log(` ${colors.symbols.radioOn} Option 2 (selected)`);
// Progress indicators
console.log(`${colors.symbols.bullet} Processing step 1`);
console.log(`${colors.symbols.bullet} Processing step 2`);
console.log(`${colors.symbols.check} All steps completed`);
// Status indicators with colors
console.log(colors.green(`${colors.symbols.check} Success`));
console.log(colors.red(`${colors.symbols.cross} Error`));
console.log(colors.yellow(`${colors.symbols.warning} Warning`));
// Lists and menus
console.log(`${colors.symbols.pointerSmall} Item 1`);
console.log(`${colors.symbols.pointerSmall} Item 2`);
console.log(`${colors.symbols.pointerSmall} Item 3`);
// Ballot boxes for checklists
console.log(`${colors.symbols.ballotOn} Completed task`);
console.log(`${colors.symbols.ballotOff} Pending task`);
console.log(`${colors.symbols.ballotDisabled} Disabled task`);
// Loading and progress
function showProgress(step, total) {
const filled = colors.symbols.fullBlock.repeat(step);
const empty = colors.symbols.middot.repeat(total - step);
console.log(`Progress: [${filled}${empty}] ${step}/${total}`);
}
showProgress(3, 10);
// Rating system
function showRating(rating, max = 5) {
const filled = colors.symbols.starsOn.repeat(rating);
const empty = colors.symbols.starsOff.repeat(max - rating);
return `${filled}${empty}`;
}
console.log(`Rating: ${showRating(4)} (4/5 stars)`);
// Platform detection (advanced usage)
const isWindows = process.platform === 'win32';
const checkSymbol = isWindows ? '√' : '✔';
console.log(`${checkSymbol} Platform-specific check`);
// Access symbol collections
console.log('Windows symbols:', colors.symbols.windows);
console.log('Other platform symbols:', colors.symbols.other);
console.log('Common symbols:', colors.symbols.common);
// Custom status function
function status(type, message) {
const symbols = {
success: colors.green(colors.symbols.check),
error: colors.red(colors.symbols.cross),
warning: colors.yellow(colors.symbols.warning),
info: colors.blue(colors.symbols.info || 'i')
};
return `${symbols[type]} ${message}`;
}
console.log(status('success', 'Operation completed'));
console.log(status('error', 'Something went wrong'));
console.log(status('warning', 'Please check your input'));
console.log(status('info', 'Processing data'));