@chromakit/core
    Preparing search index...

    Function box

    • Draw a framed box around content with optional title, padding, and colorized borders.

      Parameters

      • content: string | string[]

        The content to frame (string or array of lines).

      • opts: BoxOptions = {}

        Visual options; see BoxOptions.

      Returns string

      A multi-line string ready for terminal output.

      Layout

      • Content may be a string (split on \n) or an array of lines.
      • style is applied to each line before width measurement.
      • Inner width is max(longestLine + 2·padding, title.length + 4, width ?? 0).

      Title

      • Rendered bold and centered within the top rule.
      • Left/right fill uses the border’s horizontal glyph.

      Coloring

      • If borderColor is provided, all border segments (top/bottom/verticals) are wrapped by colorText.
      • Content itself is not colored here; pass a style if needed.

      Unicode & terminal caveats

      • Box-drawing glyphs come from the Unicode “Box Drawing” block (e.g., ┌─┐│└┘). Some fonts/terminals render them with differing cell widths, which can affect alignment. Consider sticking to ASCII (+, -, |) via the "dashed" style for maximum portability.
      • text.length counts code units; grapheme clusters (emoji/ZWJ/combining marks) may occupy multiple columns or be split visually. For perfect alignment, segment into graphemes (e.g., Intl.Segmenter) and compute display width with a wcwidth-style algorithm.
      • ANSI SGR color/reset sequences don’t consume columns but do count toward length, so styled lines can appear mismeasured unless you strip escapes before measuring.

      Basic single-line box:

      console.log(box("Hello, world!"));
      

      Titled, double border, cyan borders:

      console.log(box(["Status: OK", "All systems nominal"], {
      title: "ChromaKit",
      borderStyle: "double",
      borderColor: "cyan",
      padding: 2
      }));