titlebox

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package titlebox draws a rounded box with its title embedded in the top border - "╭ title ─────╮" - around a body the caller has already rendered. It is a framing primitive kept apart so any overlay wanting a labeled panel can reuse it without depending on a particular form.

The widget is style-agnostic: the border and title colors arrive through Styles, so a caller signals focus by handing it a different pair. It never truncates the body - a caller sizes its content to width minus Chrome and the box pads each line out to the interior.

Index

Constants

View Source
const Chrome = borderCols + 2*hPad

Chrome is the columns a titled box spends on its border and padding. A caller sizes the body it renders to the box width minus Chrome, so its content fills the interior exactly without overrunning the frame.

Variables

This section is empty.

Functions

func Render

func Render(title, body string, width int, s Styles) string

Render draws body inside a rounded box with title embedded in the top border ("╭ title ─────╮"). width is the box's total column count (border included); body is padded - never truncated - to the interior, so size it to width-Chrome. A blank title, or one too wide for the interior, draws a plain top edge. Multi-line bodies box every line.

Types

type Styles

type Styles struct {
	// Border styles the box's border glyphs.
	Border lg.Style
	// Title styles the label embedded in the top border.
	Title lg.Style
}

Styles are the box's injected render styles, so the widget stays theme-agnostic: a caller signals focus by handing it a brighter pair.

Jump to

Keyboard shortcuts

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