Card
The Card class renders a bordered box for terminal output. You give it some text, pick a width, and optionally add a title, footer, body alignment, or custom border characters. Call .render() and you get back a plain string — log it, compose it, do whatever you want with it.

Constructor
new Card(content: string,width?: CardWidth,options?: CardOptions,)
Parameters
content— the text body. Newlines are respected and long lines are wrapped automatically.width— how wide the card should be. Pass a number (minimum 12, clamped to terminal width), a ratio string like"1/2"or"2/3"or"full", or"auto"to fit the content. Defaults to50.options— optional config for title, body, footer, alignment, and border styling. SeeCardOptions.
Methods
render()— returns the fully rendered card as a styled string. Justconsole.log()it.
Border Styles
Six built-in border presets are available through border.symbols.style:
"single"—┌ ┐ └ ┘ │ ─(default)"double"—╔ ╗ ╚ ╝ ║ ═"round"—╭ ╮ ╰ ╯ │ ─"bold"—┏ ┓ ┗ ┛ ┃ ━"singleDouble"—╒ ╕ ╘ ╛ │ ═"doubleSingle"—╓ ╖ ╙ ╜ ║ ─
You can also pass border.symbols.custom with partial or full CardBorderSymbols to use your own characters.
Usage
import { Card } from "ts-better-console";
const card = new Card("Hello, World!").render();
console.log(card);
Want to support this project?
If you find ts-better-console useful and want to support its development, consider starring the GitHub repository or buying me a coffee! Your support helps me dedicate more time to improving the library and adding new features.
Want to contribute to this project?
Contributions are welcome! If you're interested in improving the library, fixing bugs, or adding new features, feel free to check out the GitHub repository and submit a pull request. Whether you're a seasoned developer or new to open source, your contributions can make a difference!