{"id":16959,"library":"cli-boxes","title":"CLI Boxes","description":"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.","status":"active","version":"4.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/sindresorhus/cli-boxes","tags":["javascript","cli","box","boxes","terminal","term","console","ascii","unicode","typescript"],"install":[{"cmd":"npm install cli-boxes","lang":"bash","label":"npm"},{"cmd":"yarn add cli-boxes","lang":"bash","label":"yarn"},{"cmd":"pnpm add cli-boxes","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"const cliBoxes = require('cli-boxes');","symbol":"cliBoxes","correct":"import cliBoxes from 'cli-boxes';"},{"note":"Access individual box definitions as properties of the default export. The structure of these objects changed in v3.0.0 for custom box definitions.","symbol":"cliBoxes.single","correct":"import cliBoxes from 'cli-boxes';\nconst singleBox = cliBoxes.single;"},{"note":"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.","symbol":"Box","correct":"import type { Box } from 'cli-boxes';"}],"quickstart":{"code":"import cliBoxes from 'cli-boxes';\n\n// Log the character definitions for the 'single' box style\nconsole.log(cliBoxes.single);\n/*\n{\n\ttopLeft: '┌',\n\ttop: '─',\n\ttopRight: '┐',\n\tright: '│',\n\tbottomRight: '┘',\n\tbottom: '─',\n\tbottomLeft: '└',\n\tleft: '│'\n}\n*/\n\n// You can use these characters to construct a box\nconst { topLeft, top, topRight, left, right, bottomLeft, bottom, bottomRight } = cliBoxes.double;\nconsole.log(topLeft + top.repeat(5) + topRight);\nconsole.log(left + ' Hello ' + right);\nconsole.log(bottomLeft + bottom.repeat(5) + bottomRight);","lang":"typescript","description":"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."},"warnings":[{"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`).","message":"Version 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.","severity":"breaking","affected_versions":">=4.0.0"},{"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.","message":"Version 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.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Update your code to use the camelCase names `cliBoxes.singleDouble` and `cliBoxes.doubleSingle` instead of `cliBoxes['single-double']` and `cliBoxes['double-single']`.","message":"Version 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.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"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`.","cause":"`cli-boxes` version 4.0.0 and above is pure ESM, but your project is trying to import it using CommonJS `require()` syntax.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ...cli-boxes/index.js from ... not supported."},{"fix":"Update your custom box definitions to use the new property names: `left`, `right`, `top`, and `bottom` instead of `vertical` and `horizontal`.","cause":"You are attempting to access `vertical` or `horizontal` properties on a custom box definition using `cli-boxes` version 3.0.0 or higher.","error":"TypeError: Cannot read properties of undefined (reading 'vertical')"},{"fix":"Use the camelCase equivalent for the box name, e.g., `cliBoxes.singleDouble` instead of `cliBoxes['single-double']`.","cause":"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.","error":"TypeError: Cannot read properties of undefined (reading 'single-double')"}],"ecosystem":"npm","meta_description":null}