box

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package box renders framed boxes around arbitrary text: rounded, hard, double, and ascii corners, an optional title in the top border, padding, and width fitting or wrapping. Content may carry ANSI styling; borders measure visible glyphs so alignment holds.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(w io.Writer, content string, opts Options, scheme style.Scheme) error

Render writes String(content, opts, scheme) to w.

func String

func String(content string, opts Options, scheme style.Scheme) string

String renders content as a framed box and always ends the result with a newline. Tabs expand to 8 columns and trailing newlines are dropped before framing. scheme gates frame colors, so a disabled scheme yields plain text.

Types

type Options

type Options struct {
	// Style picks the frame glyphs; zero is StyleRounded.
	Style Style
	// Title renders in the top border, e.g. ╭─ Warning ─╮, and is
	// truncated with an ellipsis when the box is too narrow.
	Title string
	// Padding is the inner horizontal spaces between frame and
	// content; negative values clamp to zero.
	Padding int
	// Width is the total outer width including the frame. Zero fits
	// the content; a positive value wraps content to fit, clamping to
	// one content column when smaller than the frame. StyleNone
	// measures Width against the content alone.
	Width int
	// Frame colors the frame glyphs. Zero (the engine's Reset
	// attribute) leaves the frame plain.
	Frame style.Attribute
}

Options tunes a box. The zero value renders a rounded frame sized to the content with no padding.

type Style

type Style int

Style selects the frame glyph set. Unknown values render as rounded.

const (
	StyleRounded Style = iota
	StyleHard
	StyleDouble
	StyleASCII
	StyleNone
)

Frame styles.

func (Style) String

func (s Style) String() string

String names the style.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL