rawtable

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column[T any] struct {
	// Title is the column header text
	Title string

	// String extracts the cell value from a row as a plain string
	String func(row T) string

	// Style applies styling to a cell value (optional, can be nil)
	Style func(rendered string, row T) string

	// AlignRight aligns the content to the right (default is left)
	AlignRight bool
}

Column defines a single column.

type Option

type Option[T any] func(*Table[T])

Option is a functional option for configuring a Table.

func WithHeaderStyle

func WithHeaderStyle[T any](style lipgloss.Style) Option[T]

WithHeaderStyle sets the style for column headers.

func WithStylesDisabled

func WithStylesDisabled[T any](disabled bool) Option[T]

WithStylesDisabled sets whether to disable styles.

type Table

type Table[T any] struct {
	// contains filtered or unexported fields
}

Table represents a simple table renderer for struct data.

func New

func New[T any](columns []Column[T], opts ...Option[T]) *Table[T]

New creates a new Table with the given columns.

func (*Table[T]) Render

func (t *Table[T]) Render(rows []T) string

Render renders the table with the given data rows and returns a string.

Jump to

Keyboard shortcuts

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