styles

package
v1.25.6 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 15 Imported by: ? 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

Index

Constants

This section is empty.

Variables

View Source
var (
	Link    = func() lipgloss.Style { return attr(lipgloss.NewStyle().Underline(true)) }
	Muted   = func() lipgloss.Style { return lipgloss.NewStyle().Foreground(color(lipgloss.BrightBlack)) }
	Good    = func() lipgloss.Style { return lipgloss.NewStyle().Foreground(color(lipgloss.Green)) }
	Warning = func() lipgloss.Style { return lipgloss.NewStyle().Foreground(color(lipgloss.Yellow)) }
	Bad     = func() lipgloss.Style { return lipgloss.NewStyle().Foreground(color(lipgloss.Red)) }
	Strong  = func() lipgloss.Style { return attr(lipgloss.NewStyle().Bold(true)) }
	Note    = func() lipgloss.Style { return attr(lipgloss.NewStyle().Italic(true)) }
	// Hint is secondary text. Faint dims the theme's own text color, which
	// stays readable where gray is not, and terminals without it show
	// normal text.
	Hint = func() lipgloss.Style { return attr(lipgloss.NewStyle().Faint(true)) }
)

Text styles shared by the tables. Colors are the terminal's own ANSI colors, as in ddev tui, so they follow its theme. Gray, the theme's bright black, is unreadable in some themes, so it marks only borders and status symbols, never text that must be read. Blue is too dark on many dark backgrounds, so headers are bold and links underlined, without color.

View Source
var DefaultTableStyle = "StyleLight"

Functions

func ColorEnabled added in v1.25.6

func ColorEnabled() bool

ColorEnabled reports whether output gets colors: styling is on, and neither NO_COLOR nor CLICOLOR=0 is set.

func FitColumnWidths added in v1.25.6

func FitColumnWidths(natural []int, available int) []int

FitColumnWidths returns the natural widths when they fit in available. Otherwise the widest columns are capped at one shared width, lowered until the row fits or it reaches minWidth, so narrow columns keep their full width and the space goes where it's needed.

func GetTableStyle

func GetTableStyle(name string) (style table.Style)

GetTableStyle Get a style by name, returning the default if not found

func SetGlobalTableStyle

func SetGlobalTableStyle(writer table.Writer, useSimpleFormatting bool)

SetGlobalTableStyle sets the table style to the globally configured style

func SimpleFormattingRequired

func SimpleFormattingRequired() bool

SimpleFormattingRequired returns true if we should not be colorizing/styling text

func StylingEnabled added in v1.25.6

func StylingEnabled() bool

StylingEnabled reports whether output gets text attributes such as bold, and status symbols: stdout is a terminal and simple formatting is off.

Types

type Table added in v1.25.6

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

Table is a table rendered with lipgloss in the look of the configured table_style. Callers add cells, which may hold color and OSC 8 hyperlinks, optionally limit column widths, and render. With simple formatting it is plain text without borders.

func NewTable added in v1.25.6

func NewTable(headers ...string) *Table

NewTable returns an empty table with headers.

func (*Table) AppendRow added in v1.25.6

func (t *Table) AppendRow(cells ...string)

AppendRow adds a row. Missing trailing cells are empty.

func (*Table) FitTerminal added in v1.25.6

func (t *Table) FitTerminal()

FitTerminal limits the columns' widths so the table fits the terminal, unless it is set to be unlimited. Piped output and simple formatting keep full widths, so scripts can match whole values.

func (*Table) NaturalWidths added in v1.25.6

func (t *Table) NaturalWidths() []int

NaturalWidths returns the widest line of each column, header and footer included.

func (*Table) Overhead added in v1.25.6

func (t *Table) Overhead() int

Overhead returns the width that borders and padding add to the columns' content in the configured style.

func (*Table) Render added in v1.25.6

func (t *Table) Render() string

Render returns the table as text ending in a newline.

func (*Table) SetColumnStyle added in v1.25.6

func (t *Table) SetColumnStyle(col int, style lipgloss.Style)

SetColumnStyle sets the text style of a column's cells.

func (*Table) SetFooter added in v1.25.6

func (t *Table) SetFooter(cells ...string)

SetFooter sets a last row, separated from the others by a line.

func (*Table) SetMaxWidths added in v1.25.6

func (t *Table) SetMaxWidths(widths ...int)

SetMaxWidths limits the content width of each column, 0 for no limit. Text in a column wider than its limit wraps.

func (*Table) SetSnip added in v1.25.6

func (t *Table) SetSnip(col int)

SetSnip makes a one-line cell, or a line without spaces, in column col that is wider than the column's limit end in "…" instead of wrapping. Its hyperlink keeps the full target.

func (*Table) SetTitle added in v1.25.6

func (t *Table) SetTitle(lines ...string)

SetTitle sets lines shown above the table.

func (*Table) SetUnlimited added in v1.25.6

func (t *Table) SetUnlimited(unlimited bool)

SetUnlimited ignores the width limits, so nothing is wrapped or snipped.

func (*Table) SortBy added in v1.25.6

func (t *Table) SortBy(col int)

SortBy sorts the rows by the visible text of column col.

Jump to

Keyboard shortcuts

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