layout

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package layout provides consistent border styles and spacing utilities for TUI layout. ABOUTME: Border styles and spacing utilities for consistent TUI layout ABOUTME: Provides responsive layout components with Dracula theme integration

Index

Constants

This section is empty.

Variables

View Source
var (
	// RoundedBorder uses rounded corners
	RoundedBorder = BorderSet{
		TopLeft:     "╭",
		Top:         "─",
		TopRight:    "╮",
		Right:       "│",
		BottomRight: "╯",
		Bottom:      "─",
		BottomLeft:  "╰",
		Left:        "│",
	}

	// ThickBorder uses thick lines
	ThickBorder = BorderSet{
		TopLeft:     "┏",
		Top:         "━",
		TopRight:    "┓",
		Right:       "┃",
		BottomRight: "┛",
		Bottom:      "━",
		BottomLeft:  "┗",
		Left:        "┃",
	}

	// DoubleBorder uses double lines
	DoubleBorder = BorderSet{
		TopLeft:     "╔",
		Top:         "═",
		TopRight:    "╗",
		Right:       "║",
		BottomRight: "╝",
		Bottom:      "═",
		BottomLeft:  "╚",
		Left:        "║",
	}

	// NormalBorder uses standard box drawing characters
	NormalBorder = BorderSet{
		TopLeft:     "┌",
		Top:         "─",
		TopRight:    "┐",
		Right:       "│",
		BottomRight: "┘",
		Bottom:      "─",
		BottomLeft:  "└",
		Left:        "│",
	}
)

Common border sets

Functions

func Box

func Box(content string, t *theme.Theme) string

Box creates a simple box around content

func FocusedBox

func FocusedBox(content string, t *theme.Theme) string

FocusedBox creates a focused box around content

func JoinHorizontal

func JoinHorizontal(spacing int, elements ...string) string

JoinHorizontal joins multiple strings horizontally with spacing

func JoinVertical

func JoinVertical(spacing int, elements ...string) string

JoinVertical joins multiple strings vertically with spacing

func MaxWidth

func MaxWidth(width int, content string) string

MaxWidth constrains content to a maximum width with word wrapping

func PaddedContent

func PaddedContent(content string, padding SpacingConfig) string

PaddedContent adds padding to content without borders

func PlaceHorizontal

func PlaceHorizontal(width int, pos lipgloss.Position, content string) string

PlaceHorizontal positions content horizontally within a width

func PlaceVertical

func PlaceVertical(height int, pos lipgloss.Position, content string) string

PlaceVertical positions content vertically within a height

func Separator

func Separator(width int, color lipgloss.Color) string

Separator creates a horizontal separator line

func TitledBox

func TitledBox(content, title string, t *theme.Theme) string

TitledBox creates a box with a title

func VerticalSeparator

func VerticalSeparator(height int, color lipgloss.Color) string

VerticalSeparator creates a vertical separator

Types

type BorderSet

type BorderSet struct {
	TopLeft     string
	Top         string
	TopRight    string
	Right       string
	BottomRight string
	Bottom      string
	BottomLeft  string
	Left        string
}

BorderSet represents a complete set of border characters

type BorderStyle

type BorderStyle struct {
	Border     BorderSet
	Color      lipgloss.Color
	Style      lipgloss.Style
	Spacing    SpacingConfig
	Width      int
	Height     int
	Title      string
	TitleAlign lipgloss.Position
	Focused    bool
	// contains filtered or unexported fields
}

BorderStyle creates a lipgloss border style with Dracula theme colors

func NewBorderStyle

func NewBorderStyle(t *theme.Theme) *BorderStyle

NewBorderStyle creates a new border style with Dracula theme

func (*BorderStyle) Render

func (b *BorderStyle) Render(content string) string

Render applies the border and spacing to content

func (*BorderStyle) WithBorder

func (b *BorderStyle) WithBorder(border BorderSet) *BorderStyle

WithBorder sets the border character set

func (*BorderStyle) WithColor

func (b *BorderStyle) WithColor(color lipgloss.Color) *BorderStyle

WithColor sets the border color

func (*BorderStyle) WithFocus

func (b *BorderStyle) WithFocus(focused bool) *BorderStyle

WithFocus sets whether the border is focused

func (*BorderStyle) WithSize

func (b *BorderStyle) WithSize(width, height int) *BorderStyle

WithSize sets the width and height

func (*BorderStyle) WithSpacing

func (b *BorderStyle) WithSpacing(spacing SpacingConfig) *BorderStyle

WithSpacing sets the spacing configuration

func (*BorderStyle) WithTitle

func (b *BorderStyle) WithTitle(title string, align lipgloss.Position) *BorderStyle

WithTitle sets the title and its alignment

type SpacingConfig

type SpacingConfig struct {
	PaddingTop    int
	PaddingRight  int
	PaddingBottom int
	PaddingLeft   int
	MarginTop     int
	MarginRight   int
	MarginBottom  int
	MarginLeft    int
}

SpacingConfig defines padding and margin settings

func NewMargin

func NewMargin(top, right, bottom, left int) SpacingConfig

NewMargin creates a SpacingConfig with only margin

func NewPadding

func NewPadding(top, right, bottom, left int) SpacingConfig

NewPadding creates a SpacingConfig with only padding

func NewSpacing

func NewSpacing(padding, margin int) SpacingConfig

NewSpacing creates a SpacingConfig with uniform padding and margin

Jump to

Keyboard shortcuts

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