panel

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 3 Imported by: 0

README

Panel

Bordered container with optional title and footer.

panel preview

Install

glyph add panel

This copies panel.go (and its test file) into your repo at the path your glyph.json aliases declare. After install, the file is yours: edit it, refactor it, rename it. There is no panel library to keep in sync.

Hello, world

package main

import (
	"fmt"

	"github.com/truffle-dev/glyph/components/panel"
	"github.com/truffle-dev/glyph/components/theme"
)

func main() {
	p := panel.New(theme.Default).
		WithTitle("Logs").
		WithFooter("3 entries").
		WithContent("...")
	fmt.Println(p.View())
}

API surface

Package: panel

Types

  • Variant
  • Panel

Functions and methods

  • New
  • WithTitle
  • WithFooter
  • WithContent
  • WithWidth
  • WithHeight
  • WithVariant
  • WithPadding
  • View

Dependencies

  • glyph component theme (installed automatically)
  • github.com/charmbracelet/lipgloss@v1.1.0

Notes

Panel is pure render: no Update, no Cmd. Compose other components by setting their View() output as the content. Use WithWidth/WithHeight to clamp the outer dimensions, or omit both for natural sizing.

See also

License

MIT, same as the rest of glyph.

Documentation

Overview

Package panel wraps arbitrary content in a bordered container with an optional title and footer. It's the workhorse layout primitive: almost every other component pairs well inside a Panel.

A Panel doesn't update or animate; it's a pure render wrapper. Set width to clamp the inner content area; height 0 means "natural height" (the content's line count).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Panel

type Panel struct {
	// contains filtered or unexported fields
}

Panel is a bordered container with optional title and footer.

func New

func New(t theme.Theme) Panel

New constructs a Panel using the default variant.

func (Panel) View

func (p Panel) View() string

View renders the bordered panel.

func (Panel) WithContent

func (p Panel) WithContent(c string) Panel

func (Panel) WithFooter

func (p Panel) WithFooter(footer string) Panel

func (Panel) WithHeight

func (p Panel) WithHeight(h int) Panel

WithHeight clamps the outer panel height (including borders). Values <= 0 mean natural height.

func (Panel) WithPadding

func (p Panel) WithPadding(x, y int) Panel

WithPadding sets horizontal and vertical padding inside the borders.

func (Panel) WithTitle

func (p Panel) WithTitle(title string) Panel

func (Panel) WithVariant

func (p Panel) WithVariant(v Variant) Panel

WithVariant selects the border weight.

func (Panel) WithWidth

func (p Panel) WithWidth(w int) Panel

WithWidth clamps the outer panel width (including borders). Values <= 0 mean natural width.

type Variant

type Variant int

Variant tunes border weight. Default uses theme.Border (subtle); Strong uses theme.BorderStrong (high contrast).

const (
	VariantDefault Variant = iota
	VariantStrong
)

Jump to

Keyboard shortcuts

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