{"id":13396674,"url":"https://github.com/sindresorhus/boxen","last_synced_at":"2025-05-13T19:12:27.998Z","repository":{"id":37412589,"uuid":"48394154","full_name":"sindresorhus/boxen","owner":"sindresorhus","description":"Create boxes in the terminal","archived":false,"fork":false,"pushed_at":"2024-08-05T11:05:06.000Z","size":162,"stargazers_count":1594,"open_issues_count":7,"forks_count":59,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-05-13T14:16:38.283Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2015-12-21T21:06:17.000Z","updated_at":"2025-05-11T11:34:13.000Z","dependencies_parsed_at":"2024-11-05T19:55:09.026Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/boxen","commit_stats":{"total_commits":123,"total_committers":23,"mean_commits":"5.3478260869565215","dds":0.3902439024390244,"last_synced_commit":"52bbd6a57e92ea0dac762677d21ab5787a8abc39"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fboxen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fboxen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fboxen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fboxen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/boxen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254010813,"owners_count":21998993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T18:00:59.771Z","updated_at":"2025-05-13T19:12:27.953Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["JavaScript","打印","Packages","第三方库介绍","Repository","包","Uncategorized","Command-line utilities","目录","Colorize","Node.js / JavaScript 🟨"],"sub_categories":["Command-line utilities","脚手架","Command-line Utilities","命令行工具","Uncategorized","Node","命令行实用工具"],"readme":"# boxen\n\n\u003e Create boxes in the terminal\n\n![](screenshot.png)\n\n## Install\n\n```sh\nnpm install boxen\n```\n\n## Usage\n\n```js\nimport boxen from 'boxen';\n\nconsole.log(boxen('unicorn', {padding: 1}));\n/*\n┌─────────────┐\n│             │\n│   unicorn   │\n│             │\n└─────────────┘\n*/\n\nconsole.log(boxen('unicorn', {padding: 1, margin: 1, borderStyle: 'double'}));\n/*\n\n   ╔═════════════╗\n   ║             ║\n   ║   unicorn   ║\n   ║             ║\n   ╚═════════════╝\n\n*/\n\nconsole.log(boxen('unicorns love rainbows', {title: 'magical', titleAlignment: 'center'}));\n/*\n┌────── magical ───────┐\n│unicorns love rainbows│\n└──────────────────────┘\n*/\n```\n\n## API\n\n### boxen(text, options?)\n\n#### text\n\nType: `string`\n\nText inside the box.\n\n#### options\n\nType: `object`\n\n##### borderColor\n\nType: `string`\\\nValues: `'black'` `'red'` `'green'` `'yellow'` `'blue'` `'magenta'` `'cyan'` `'white'` `'gray'` or a hex value like `'#ff0000'`\n\nColor of the box border.\n\n##### borderStyle\n\nType: `string | object`\\\nDefault: `'single'`\\\nValues:\n- `'single'`\n```\n┌───┐\n│foo│\n└───┘\n```\n- `'double'`\n```\n╔═══╗\n║foo║\n╚═══╝\n```\n- `'round'` (`'single'` sides with round corners)\n```\n╭───╮\n│foo│\n╰───╯\n```\n- `'bold'`\n```\n┏━━━┓\n┃foo┃\n┗━━━┛\n```\n- `'singleDouble'` (`'single'` on top and bottom, `'double'` on right and left)\n```\n╓───╖\n║foo║\n╙───╜\n```\n- `'doubleSingle'` (`'double'` on top and bottom, `'single'` on right and left)\n```\n╒═══╕\n│foo│\n╘═══╛\n```\n- `'classic'`\n```\n+---+\n|foo|\n+---+\n```\n- `'arrow'`\n```\n↘↓↓↓↙\n→foo←\n↗↑↑↑↖\n```\n- `'none'`\n```\nfoo\n```\n\nStyle of the box border.\n\nCan be any of the above predefined styles or an object with the following keys:\n\n```js\n{\n\ttopLeft: '+',\n\ttopRight: '+',\n\tbottomLeft: '+',\n\tbottomRight: '+',\n\ttop: '-',\n\tbottom: '-',\n\tleft: '|',\n\tright: '|'\n}\n```\n\n##### dimBorder\n\nType: `boolean`\\\nDefault: `false`\n\nReduce opacity of the border.\n\n##### title\n\nType: `string`\n\nDisplay a title at the top of the box.\nIf needed, the box will horizontally expand to fit the title.\n\nExample:\n```js\nconsole.log(boxen('foo bar', {title: 'example'}));\n/*\n┌ example ┐\n│foo bar  │\n└─────────┘\n*/\n```\n\n##### titleAlignment\n\nType: `string`\\\nDefault: `'left'`\n\nAlign the title in the top bar.\n\nValues:\n- `'left'`\n```js\n/*\n┌ example ──────┐\n│foo bar foo bar│\n└───────────────┘\n*/\n```\n- `'center'`\n```js\n/*\n┌─── example ───┐\n│foo bar foo bar│\n└───────────────┘\n*/\n```\n- `'right'`\n```js\n/*\n┌────── example ┐\n│foo bar foo bar│\n└───────────────┘\n*/\n```\n\n##### width\n\nType: `number`\n\nSet a fixed width for the box.\n\n*Note:* This disables terminal overflow handling and may cause the box to look broken if the user's terminal is not wide enough.\n\n```js\nimport boxen from 'boxen';\n\nconsole.log(boxen('foo bar', {width: 15}));\n// ┌─────────────┐\n// │foo bar      │\n// └─────────────┘\n```\n\n##### height\n\nType: `number`\n\nSet a fixed height for the box.\n\n*Note:* This option will crop overflowing content.\n\n```js\nimport boxen from 'boxen';\n\nconsole.log(boxen('foo bar', {height: 5}));\n// ┌───────┐\n// │foo bar│\n// │       │\n// │       │\n// └───────┘\n```\n\n##### fullscreen\n\nType: `boolean | (width: number, height: number) =\u003e [width: number, height: number]`\n\nWhether or not to fit all available space within the terminal.\n\nPass a callback function to control box dimensions:\n\n```js\nimport boxen from 'boxen';\n\nconsole.log(boxen('foo bar', {\n\tfullscreen: (width, height) =\u003e [width, height - 1],\n}));\n```\n\n##### padding\n\nType: `number | object`\\\nDefault: `0`\n\nSpace between the text and box border.\n\nAccepts a number or an object with any of the `top`, `right`, `bottom`, `left` properties. When a number is specified, the left/right padding is 3 times the top/bottom to make it look nice.\n\n##### margin\n\nType: `number | object`\\\nDefault: `0`\n\nSpace around the box.\n\nAccepts a number or an object with any of the `top`, `right`, `bottom`, `left` properties. When a number is specified, the left/right margin is 3 times the top/bottom to make it look nice.\n\n##### float\n\nType: `string`\\\nDefault: `'left'`\\\nValues: `'right'` `'center'` `'left'`\n\nFloat the box on the available terminal screen space.\n\n##### backgroundColor\n\nType: `string`\\\nValues: `'black'` `'red'` `'green'` `'yellow'` `'blue'` `'magenta'` `'cyan'` `'white'` `'gray'` or a hex value like `'#ff0000'`\n\nColor of the background.\n\n##### textAlignment\n\nType: `string`\\\nDefault: `'left'`\\\nValues: `'left'` `'center'` `'right'`\n\nAlign the text in the box based on the widest line.\n\n## Maintainer\n\n- [Sindre Sorhus](https://github.com/sindresorhus)\n- [Caesarovich](https://github.com/Caesarovich)\n\n## Related\n\n- [boxen-cli](https://github.com/sindresorhus/boxen-cli) - CLI for this module\n- [cli-boxes](https://github.com/sindresorhus/cli-boxes) - Boxes for use in the terminal\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fboxen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fboxen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fboxen/lists"}