Registry / http-networking / cli-boxes

cli-boxes

JSON →
library4.0.1jsnpmunverified

cli-boxes is a utility package providing a collection of pre-defined ASCII and Unicode box character sets, formatted as JSON objects, for rendering borders in terminal applications. It is currently at version 4.0.1 and is actively maintained by Sindre Sorhus, with releases primarily driven by Node.js LTS version compatibility and major architectural shifts like the move to pure ESM. Unlike full terminal UI libraries, cli-boxes focuses solely on delivering the raw character data, allowing other packages (like `boxen`) to handle the actual drawing logic. This makes it a lightweight and foundational component for console-based interfaces, distinguishing it from more comprehensive alternatives by its single-purpose design.

npm install cli-boxes
INSTALL
IMPORT
SIG · CLI-BOXES
C
cli-boxes
http-networkingjavascriptv4.0.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cliBoxes
✓ import cliBoxes from 'cli-boxes';
✗ const cliBoxes = require('cli-boxes');
Since v4.0.0, cli-boxes is a pure ESM package and cannot be imported using CommonJS `require()`. Ensure your project is configured for ESM or use an older version.
cliBoxes.single
✓ import cliBoxes from 'cli-boxes'; const singleBox = cliBoxes.single;
Access individual box definitions as properties of the default export. The structure of these objects changed in v3.0.0 for custom box definitions.
Box
✓ import type { Box } from 'cli-boxes';
While `cli-boxes` exports types, the primary usage often involves direct access to the `cliBoxes` object without explicitly importing its internal type definitions unless needed for custom type declarations.

Demonstrates importing the `cli-boxes` module, accessing the character definitions for the 'single' and 'double' box styles, and a simple example of how to use them to print a basic box in the terminal.

import cliBoxes from 'cli-boxes'; // Log the character definitions for the 'single' box style console.log(cliBoxes.single); /* { topLeft: '┌', top: '─', topRight: '┐', right: '│', bottomRight: '┘', bottom: '─', bottomLeft: '└', left: '│' } */ // You can use these characters to construct a box const { topLeft, top, topRight, left, right, bottomLeft, bottom, bottomRight } = cliBoxes.double; console.log(topLeft + top.repeat(5) + topRight); console.log(left + ' Hello ' + right); console.log(bottomLeft + bottom.repeat(5) + bottomRight);
Debug
Known issues
breakingVersion 4.0.0 of `cli-boxes` is pure ESM (ECMAScript Modules) and requires Node.js 18 or higher. Projects using CommonJS or older Node.js versions must either remain on `cli-boxes@3.x` or refactor to use ESM.
fix
Migrate your project to use ES modules by setting `"type": "module"` in `package.json`, updating your `import` statements, and ensuring Node.js 18+ is installed. For CommonJS projects that cannot migrate, pin `cli-boxes` to a version lower than 4.0.0 (e.g., `^3.0.0`).
affects: >=4.0.0
breakingVersion 3.0.0 introduced a change in the configuration keys for custom box definitions. The `vertical` and `horizontal` keys were renamed to `left`, `right`, `top`, and `bottom` respectively. This affects users providing custom box objects.
fix
Update any custom box definitions to use the new key names: `vertical` becomes `left` and `right`, `horizontal` becomes `top` and `bottom`. Refer to the diff provided in the v3.0.0 release notes.
affects: >=3.0.0
breakingVersion 2.0.0 renamed two box styles: `single-double` became `singleDouble` and `double-single` became `doubleSingle`. Accessing the old hyphenated names will result in undefined values.
fix
Update your code to use the camelCase names `cliBoxes.singleDouble` and `cliBoxes.doubleSingle` instead of `cliBoxes['single-double']` and `cliBoxes['double-single']`.
affects: >=2.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module ...cli-boxes/index.js from ... not supported.
`cli-boxes` version 4.0.0 and above is pure ESM, but your project is trying to import it using CommonJS `require()` syntax.
fix
Change your `require('cli-boxes')` statement to `import cliBoxes from 'cli-boxes';` and ensure your `package.json` has `"type": "module"` or your file uses the `.mjs` extension. Upgrade Node.js to version 18 or higher. If you cannot migrate to ESM, downgrade `cli-boxes` to version `3.x`.
TypeError: Cannot read properties of undefined (reading 'vertical')
You are attempting to access `vertical` or `horizontal` properties on a custom box definition using `cli-boxes` version 3.0.0 or higher.
fix
Update your custom box definitions to use the new property names: `left`, `right`, `top`, and `bottom` instead of `vertical` and `horizontal`.
TypeError: Cannot read properties of undefined (reading 'single-double')
You are trying to access a box style using its old, hyphenated name (e.g., 'single-double') with `cli-boxes` version 2.0.0 or higher.
fix
Use the camelCase equivalent for the box name, e.g., `cliBoxes.singleDouble` instead of `cliBoxes['single-double']`.
Upgrade
Version history
4.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
18
Amazon
1
OpenAI (training)
1
Resources
cli-boxes — npm install cli-boxes · libregistry