Skip to content

Box

import { box } from "@mongez/copper";
console.log(
box("Deploy successful", {
borderStyle: "round",
borderColor: "green",
padding: 1,
}),
);
╭─────────────────────╮
│ │
│ Deploy successful │
│ │
╰─────────────────────╯

Options

OptionDefaultNote
padding1Internal blank lines + side spaces
margin0Blank lines above and below the box
borderStyle"round""single" "double" "round" "bold" "ascii"
borderColor(none)Any ColorName
align"left""left" "center" "right"

Border styles

StyleSample
single┌─┐ │ └─┘
double╔═╗ ║ ╚═╝
round╭─╮ │ ╰─╯
bold┏━┓ ┃ ┗━┛
ascii+-+ | +-+ — for terminals that don’t render box-drawing

Multi-line content

box("Line one\nLonger second line\nThird", { align: "center" });

All lines are padded to the longest one, so the right border lines up. Width measurement strips ANSI first, so colored lines (box(colors.red("…"))) don’t skew the box.