CardOptions

Configuration for the Card class. Controls the title, body, footer, alignment on the terminal, and border appearance.

Type Definition

interface CardOptions {
  title?: SectionOptions;
  body?: BodyOptions;
  align?: Alignment;
  footer?: SectionOptions;
  border?: BorderOptions;
}

Properties

  • title — a SectionOptions with content, optional align, and optional style. Renders a title row above the body with a separator line.
  • body — a BodyOptions object with align and style to control the main content area.
  • align — positions the entire card on the terminal: "left", "center", or "right".
  • footer — same shape as title. Renders a footer row below the body with a separator line.
  • border — a BorderOptions object with:
    • style — a StyleOptions to color/style the border characters.
    • symbols — pick a preset with symbols.style ("single", "double", "round", "bold", "singleDouble", "doubleSingle") or supply your own with symbols.custom.

Usage

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

const card = new Card("Hello World", 50, {
title: {
content: "My Card",
style: { color: "cyan", styles: ["bold"] },
},
body: { style: { color: "white" } },
footer: { content: "v1.0.0", style: { color: "gray" } },
border: {
style: { color: "blue" },
symbols: { style: "round" },
},
}).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!