console-text-box

1.1.9 • Public • Published

Console Text Box

Zero dependency console text box. Inspired by the npm message

Use

Include each line as a separate argument, a \n and backtick ` strings on a new line will be considered a new line.

Optionally can include options as first argument as an object and they are listed as below

Options

sideBuffer: [default 3] Spaces on left of right inside the box.

topBottomBuffer: [default 1] Spaces on top and bottom inside the box.

Examples

Excuse some examples as the spaces don't render properly on some browsers, the boxes should align properly when used in console. If you know of a way to get them to look consistent in .md format let me know :)

const consoleTextBox = require('console-text-box')

consoleTextBox('hey', 'dude');

╭──────────╮
│          │
│   hey    │
│   dude   │
│          │
╰──────────╯
consoleTextBox('hey', 'dude', 'im kind of long, can you see?', 'i have a \n new line', `im a multi
line back tick`);
╭───────────────────────────────────╮
│                                   │
│                hey                │
│               dude                │
│   im kind of long, can you see?   │
│             i have a              │
│             new line              │
│            im a multi             │
│          line back tick           │
│                                   │
╰───────────────────────────────────╯
consoleTextBox({sideBuffer: 1, topBottomBuffer: 0}, 'I have options', 'Look at me mum');
╭────────────────╮
│ I have options │
│ Look at me mum │
╰────────────────╯
const myBoundTextBox = consoleTextBox.bind(null, {sideBuffer: 0, topBottomBuffer: 0});
myBoundTextBox('I have options', 'bound 2');
╭──────────────╮
│I have options│
│   bound 2    │
╰──────────────╯
const myClosureTextBox = (...textLines) => consoleTextBox({sideBuffer: 1, topBottomBuffer: 2}, ...textLines);
myClosureTextBox('I also have options', 'I wont dis-close how i got them')
╭─────────────────────────────────╮
│                                 │
│                                 │
│       I also have options       │
│ I wont dis-close how i got them │
│                                 │
│                                 │
╰─────────────────────────────────╯

Readme

Keywords

none

Package Sidebar

Install

npm i console-text-box

Weekly Downloads

14

Version

1.1.9

License

ISC

Unpacked Size

7.19 kB

Total Files

4

Last publish

Collaborators

  • ihsanm