table

package
v1.22.3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package table provides a themed table component.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

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

Model wraps lipgloss/table with theme-aware styling.

func New

func New(theme styles.Theme, opts ...Option) *Model

New creates a new table.

func (*Model) Clear

func (m *Model) Clear()

Clear removes all rows (keeps headers).

func (*Model) Headers

func (m *Model) Headers(headers ...string)

Headers sets the column headers.

func (*Model) Row

func (m *Model) Row(cells ...string)

Row adds a single row to the table.

func (*Model) Rows

func (m *Model) Rows(rows [][]string)

Rows adds multiple rows to the table.

func (*Model) SetWidth

func (m *Model) SetWidth(width int)

SetWidth sets the maximum width for the table.

func (*Model) View

func (m *Model) View() string

View renders the table.

type Option

type Option func(*Model)

Option configures a table.

func WithBackground

func WithBackground(c color.Color) Option

WithBackground sets the background color for cells and borders. Needed because lipgloss table resets ANSI styles between cells, so a parent container's background doesn't propagate through.

func WithFitHeaders

func WithFitHeaders() Option

WithFitHeaders truncates column headers to the widest value in each column, with a minimum width of 5. Use WithMinHeaderWidth to override the minimum.

func WithMaxValueWidth

func WithMaxValueWidth(n int) Option

WithMaxValueWidth sets the maximum width for cell values. Values wider than this are truncated with an ellipsis. Default is 20.

func WithMinHeaderWidth

func WithMinHeaderWidth(n int) Option

WithMinHeaderWidth sets the minimum header width when FitHeaders is enabled.

Jump to

Keyboard shortcuts

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