Unicode symbols with fallbacks for older terminals


Keywords
unicode, cli, cmd, command-line, characters, symbol, symbols, figure, figures, fallback, command-line-utility, node-module, npm-package, terminal, unicode-symbols
License
MIT
Install
npm install figures@4.0.1

Documentation

figures

Unicode symbols with fallbacks for older terminals

and more...

Terminals such as Windows Console Host (and CMD) only support a limited character set.

Install

npm install figures

Usage

import figures, {mainSymbols, fallbackSymbols, replaceSymbols} from 'figures';

console.log(figures.tick);
// On terminals with Unicode symbols:  โœ”
// On other terminals:                 โˆš

console.log(mainSymbols.tick);
// On all terminals:  โœ”

console.log(fallbackSymbols.tick);
// On all terminals:  โˆš

console.log(replaceSymbols('โœ” check'));
// On terminals with Unicode symbols:  โœ” check
// On other terminals:                 โˆš check

API

figures (default export)

Type: object

Symbols to use on any terminal.

mainSymbols

Symbols to use when the terminal supports Unicode symbols.

fallbackSymbols

Symbols to use when the terminal does not support Unicode symbols.

replaceSymbols(string, options?)

Returns the input with replaced fallback symbols if the terminal has poor Unicode support.

All the below figures are attached to the default export as shown in the example above.

string

Type: string

String where the Unicode symbols will be replaced with fallback symbols depending on the terminal.

options

Type: object

useFallback

Type: boolean
Default: true if the terminal has poor Unicode support

Whether to replace symbols with fallbacks.

This can be set to true to always use fallback symbols, whether the terminal has poor Unicode support or not.

import {replaceSymbols} from 'figures';

console.log(replaceSymbols('โœ” check', {useFallback: true}));
// On terminals with Unicode symbols:  โˆš check
// On other terminals:                 โˆš check

Figures

Fallback characters are only shown when they differ from the Main ones.

Name Main Fallback
tick โœ” โˆš
info โ„น i
warning โš  โ€ผ
cross โœ˜ ร—
square โ–ˆ
squareSmall โ—ป โ–ก
squareSmallFilled โ—ผ โ– 
squareDarkShade โ–“
squareMediumShade โ–’
squareLightShade โ–‘
squareTop โ–€
squareBottom โ–„
squareLeft โ–Œ
squareRight โ–
squareCenter โ– 
circle โ—ฏ ( )
circleFilled โ—‰ (*)
circleDotted โ—Œ ( )
circleDouble โ—Ž ( )
circleCircle โ“ž (โ—‹)
circleCross โ“ง (ร—)
circlePipe โ’พ (โ”‚)
circleQuestionMark ?โƒ (?)
radioOn โ—‰ (*)
radioOff โ—ฏ ( )
checkboxOn โ˜’ [ร—]
checkboxOff โ˜ [ ]
checkboxCircleOn โ“ง (ร—)
checkboxCircleOff โ’พ ( )
questionMarkPrefix ?โƒ ๏ผŸ
bullet โ—
dot โ€ค
ellipsis โ€ฆ
pointer โฏ >
pointerSmall โ€บ โ€บ
triangleUp โ–ฒ
triangleUpSmall โ–ด
triangleUpOutline โ–ณ โˆ†
triangleDown โ–ผ
triangleDownSmall โ–พ
triangleLeft โ—€ โ—„
triangleLeftSmall โ—‚
triangleRight โ–ถ โ–บ
triangleRightSmall โ–ธ
lozenge โ—† โ™ฆ
lozengeOutline โ—‡ โ—Š
home โŒ‚
hamburger โ˜ฐ โ‰ก
smiley ใ‹ก โ˜บ
mustache เทด โ”Œโ”€โ”
heart โ™ฅ
star โ˜… โœถ
play โ–ถ โ–บ
musicNote โ™ช
musicNoteBeamed โ™ซ
nodejs โฌข โ™ฆ
arrowUp โ†‘
arrowDown โ†“
arrowLeft โ†
arrowRight โ†’
arrowLeftRight โ†”
arrowUpDown โ†•
almostEqual โ‰ˆ
notEqual โ‰ 
lessOrEqual โ‰ค
greaterOrEqual โ‰ฅ
identical โ‰ก
infinity โˆž
subscriptZero โ‚€
subscriptOne โ‚
subscriptTwo โ‚‚
subscriptThree โ‚ƒ
subscriptFour โ‚„
subscriptFive โ‚…
subscriptSix โ‚†
subscriptSeven โ‚‡
subscriptEight โ‚ˆ
subscriptNine โ‚‰
oneHalf ยฝ
oneThird โ…“
oneQuarter ยผ
oneFifth โ…•
oneSixth โ…™
oneSeventh โ… 1/7
oneEighth โ…›
oneNinth โ…‘ 1/9
oneTenth โ…’ 1/10
twoThirds โ…”
twoFifths โ…–
threeQuarters ยพ
threeFifths โ…—
threeEighths โ…œ
fourFifths โ…˜
fiveSixths โ…š
fiveEighths โ…
sevenEighths โ…ž
line โ”€
lineBold โ”
lineDouble โ•
lineDashed0 โ”„
lineDashed1 โ”…
lineDashed2 โ”ˆ
lineDashed3 โ”‰
lineDashed4 โ•Œ
lineDashed5 โ•
lineDashed6 โ•ด
lineDashed7 โ•ถ
lineDashed8 โ•ธ
lineDashed9 โ•บ
lineDashed10 โ•ผ
lineDashed11 โ•พ
lineDashed12 โˆ’
lineDashed13 โ€“
lineDashed14 โ€
lineDashed15 โƒ
lineVertical โ”‚
lineVerticalBold โ”ƒ
lineVerticalDouble โ•‘
lineVerticalDashed0 โ”†
lineVerticalDashed1 โ”‡
lineVerticalDashed2 โ”Š
lineVerticalDashed3 โ”‹
lineVerticalDashed4 โ•Ž
lineVerticalDashed5 โ•
lineVerticalDashed6 โ•ต
lineVerticalDashed7 โ•ท
lineVerticalDashed8 โ•น
lineVerticalDashed9 โ•ป
lineVerticalDashed10 โ•ฝ
lineVerticalDashed11 โ•ฟ
lineDownLeft โ”
lineDownLeftArc โ•ฎ
lineDownBoldLeftBold โ”“
lineDownBoldLeft โ”’
lineDownLeftBold โ”‘
lineDownDoubleLeftDouble โ•—
lineDownDoubleLeft โ•–
lineDownLeftDouble โ••
lineDownRight โ”Œ
lineDownRightArc โ•ญ
lineDownBoldRightBold โ”
lineDownBoldRight โ”Ž
lineDownRightBold โ”
lineDownDoubleRightDouble โ•”
lineDownDoubleRight โ•“
lineDownRightDouble โ•’
lineUpLeft โ”˜
lineUpLeftArc โ•ฏ
lineUpBoldLeftBold โ”›
lineUpBoldLeft โ”š
lineUpLeftBold โ”™
lineUpDoubleLeftDouble โ•
lineUpDoubleLeft โ•œ
lineUpLeftDouble โ•›
lineUpRight โ””
lineUpRightArc โ•ฐ
lineUpBoldRightBold โ”—
lineUpBoldRight โ”–
lineUpRightBold โ”•
lineUpDoubleRightDouble โ•š
lineUpDoubleRight โ•™
lineUpRightDouble โ•˜
lineUpDownLeft โ”ค
lineUpBoldDownBoldLeftBold โ”ซ
lineUpBoldDownBoldLeft โ”จ
lineUpDownLeftBold โ”ฅ
lineUpBoldDownLeftBold โ”ฉ
lineUpDownBoldLeftBold โ”ช
lineUpDownBoldLeft โ”ง
lineUpBoldDownLeft โ”ฆ
lineUpDoubleDownDoubleLeftDouble โ•ฃ
lineUpDoubleDownDoubleLeft โ•ข
lineUpDownLeftDouble โ•ก
lineUpDownRight โ”œ
lineUpBoldDownBoldRightBold โ”ฃ
lineUpBoldDownBoldRight โ” 
lineUpDownRightBold โ”
lineUpBoldDownRightBold โ”ก
lineUpDownBoldRightBold โ”ข
lineUpDownBoldRight โ”Ÿ
lineUpBoldDownRight โ”ž
lineUpDoubleDownDoubleRightDouble โ• 
lineUpDoubleDownDoubleRight โ•Ÿ
lineUpDownRightDouble โ•ž
lineDownLeftRight โ”ฌ
lineDownBoldLeftBoldRightBold โ”ณ
lineDownLeftBoldRightBold โ”ฏ
lineDownBoldLeftRight โ”ฐ
lineDownBoldLeftBoldRight โ”ฑ
lineDownBoldLeftRightBold โ”ฒ
lineDownLeftRightBold โ”ฎ
lineDownLeftBoldRight โ”ญ
lineDownDoubleLeftDoubleRightDouble โ•ฆ
lineDownDoubleLeftRight โ•ฅ
lineDownLeftDoubleRightDouble โ•ค
lineUpLeftRight โ”ด
lineUpBoldLeftBoldRightBold โ”ป
lineUpLeftBoldRightBold โ”ท
lineUpBoldLeftRight โ”ธ
lineUpBoldLeftBoldRight โ”น
lineUpBoldLeftRightBold โ”บ
lineUpLeftRightBold โ”ถ
lineUpLeftBoldRight โ”ต
lineUpDoubleLeftDoubleRightDouble โ•ฉ
lineUpDoubleLeftRight โ•จ
lineUpLeftDoubleRightDouble โ•ง
lineUpDownLeftRight โ”ผ
lineUpBoldDownBoldLeftBoldRightBold โ•‹
lineUpDownBoldLeftBoldRightBold โ•ˆ
lineUpBoldDownLeftBoldRightBold โ•‡
lineUpBoldDownBoldLeftRightBold โ•Š
lineUpBoldDownBoldLeftBoldRight โ•‰
lineUpBoldDownLeftRight โ•€
lineUpDownBoldLeftRight โ•
lineUpDownLeftBoldRight โ”ฝ
lineUpDownLeftRightBold โ”พ
lineUpBoldDownBoldLeftRight โ•‚
lineUpDownLeftBoldRightBold โ”ฟ
lineUpBoldDownLeftBoldRight โ•ƒ
lineUpBoldDownLeftRightBold โ•„
lineUpDownBoldLeftBoldRight โ•…
lineUpDownBoldLeftRightBold โ•†
lineUpDoubleDownDoubleLeftDoubleRightDouble โ•ฌ
lineUpDoubleDownDoubleLeftRight โ•ซ
lineUpDownLeftDoubleRightDouble โ•ช
lineCross โ•ณ
lineBackslash โ•ฒ
lineSlash โ•ฑ

Other characters

If you cannot find the character you're looking for in the table above, please look at this full list of cross-platform terminal characters.

Unsupported terminals

The following terminals are not officially supported:

  • xterm
  • Linux Terminal (kernel)
  • cmder

They can display most but not all of the symbols listed above.

Related