CardWidth

The CardWidth type controls how wide a card (or input) should be. You can pass a pixel number, a fraction of the terminal width, or let it figure itself out.

Type Definition

The CardWidth type accepts the following values:

  • number — a fixed width in characters. Minimum is 12; clamped to the terminal width.
  • Ratio — a fraction string: "1/2", "1/3", "2/3", or "full". Calculated relative to the terminal width.
  • "auto" — shrinks to fit the content (minimum 12 characters).
type Ratio = "1/2" | "1/3" | "2/3" | "full";

type CardWidth = number | Ratio | "auto";

Usage

You can use CardWidth to control the width of a card when creating it:

import { Card } from "ts-better-console";

// Fixed width of 40 characters
console.log(new Card("Content", 40, { }).render());

// Auto width based on content
console.log(new Card("Content", "auto", { }).render());

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!