Skip to content

Box

import { box } from "@arshad-shah/clif";
console.log(box("Hello, World!"));

Five built-in styles: round (default), single, double, bold, none.

box("round", { border: "round" }); // ╭─────╮
box("single", { border: "single" }); // ┌─────┐
box("double", { border: "double" }); // ╔═════╗
box("bold", { border: "bold" }); // ┏━━━━━┓
import { box, cyan, yellow } from "@arshad-shah/clif";
box("Content", {
title: "Notice",
align: "center",
width: 30,
borderColor: cyan,
titleColor: yellow,
dimBorder: true,
});

padding applies to every side. It controls both the horizontal space (in columns) and the vertical space (in blank lines) between the border and the content, so padding: 2 adds two spaces left/right and two blank lines top/bottom. Negative or fractional values are normalised to a non-negative integer.

box("snug", { padding: 0 }); // border hugs the content
box("roomy", { padding: 2 }); // 2 cols + 2 rows of breathing room
OptionTypeDefaultDescription
borderBoxBorder"round"Border style
titlestringTitle in top border
paddingnumber1Inner padding on every side (horizontal columns + vertical lines)
marginnumber0Outer margin
widthnumberautoMinimum inner width (the box also auto-expands to fit a long title)
align"left" | "center" | "right""left"Alignment
borderColorFormatteridentityBorder color
titleColorFormatterboldTitle color
dimBorderbooleanfalseDim the border