package table

Import Path
	charm.land/lipgloss/v2/table (on go.dev)

Dependency Relation
	imports 5 packages, and imported by one package

Involved Source Files resizing.go rows.go Package table provides a styled table renderer for terminals. util.go
Package-Level Type Names (total 7, in which 5 are exported)
/* sort exporteds by: | */
Data is the interface that wraps the basic methods of a table model. At returns the contents of the cell at the given index. Columns returns the number of columns in the table. Rows returns the number of rows in the table. *Filter *StringData func (*Table).GetData() Data func DataToMatrix(data Data) (rows [][]string) func NewFilter(data Data) *Filter func (*Table).Data(data Data) *Table
Filter applies a filter on some data. At returns the row at the given index. Columns returns the number of columns in the table. Filter applies the given filter function to the data. Rows returns the number of rows in the table. *Filter : Data func NewFilter(data Data) *Filter func (*Filter).Filter(f func(row int) bool) *Filter
StringData is a string-based implementation of the Data interface. Append appends the given row to the table. At returns the contents of the cell at the given index. Columns returns the number of columns in the table. Item appends the given row to the table. Rows returns the number of rows in the table. *StringData : Data func NewStringData(rows ...[]string) *StringData func (*StringData).Item(rows ...string) *StringData
StyleFunc is the style function that determines the style of a Cell. It takes the row and column of the cell as an input and determines the lipgloss Style to use for that cell position. Example: t := table.New(). Headers("Name", "Age"). Row("Kini", 4). Row("Eli", 1). Row("Iris", 102). StyleFunc(func(row, col int) lipgloss.Style { switch { case row == 0: return HeaderStyle case row%2 == 0: return EvenRowStyle default: return OddRowStyle } }) func (*Table).StyleFunc(style StyleFunc) *Table
Table is a type for rendering tables. BaseStyle sets the base style for the whole table. If you need to set a background color for the whole table, use this. Border sets the table border. BorderBottom sets the bottom border. BorderColumn sets the column border separator. BorderHeader sets the header separator border. BorderLeft sets the left border. BorderRight sets the right border. BorderRow sets the row border separator. BorderStyle sets the style for the table border. BorderTop sets the top border. ClearRows clears the table rows. Data sets the table data. FirstVisibleRowIndex returns the index of the first visible row in the table. FitContent configures the table to render at its content width—the width needed to fully fit its content, including cell padding and borders—rather than expanding to fill the width set via [Table.Width]. When combined with [Table.Width], the configured width acts as a maximum: the table renders at its content width unless that exceeds the maximum, in which case it's constrained to the maximum and its content is resized to fit. GetBorderBottom gets the bottom border. GetBorderColumn gets the column border separator. GetBorderHeader gets the header separator border. GetBorderLeft gets the left border. GetBorderRight gets the right border. GetBorderRow gets the row border separator. GetBorderTop gets the top border. GetData returns the table data. GetHeaders returns the table headers. GetHeight returns the height of the table. GetYOffset returns the table rendering offset. Headers sets the table headers. Height sets the table height. LastVisibleRowIndex returns the index of the last visible row in the table. Render returns the table as a string. Row appends a row to the table data. Rows appends rows to the table data. String returns the table as a string. StyleFunc sets the style for a cell based on it's position (row, column). VisibleRows returns the number of visible rows in the table. Width sets the table width, this auto-sizes the columns to fit the width by either expanding or contracting the widths of each column as a best effort approach. Wrap dictates whether or not the table content should wrap. This only applies to data cells. Headers are never wrapped. YOffset sets the table rendering offset. *Table : expvar.Var *Table : fmt.Stringer func New() *Table func (*Table).BaseStyle(baseStyle lipgloss.Style) *Table func (*Table).Border(border lipgloss.Border) *Table func (*Table).BorderBottom(v bool) *Table func (*Table).BorderColumn(v bool) *Table func (*Table).BorderHeader(v bool) *Table func (*Table).BorderLeft(v bool) *Table func (*Table).BorderRight(v bool) *Table func (*Table).BorderRow(v bool) *Table func (*Table).BorderStyle(style lipgloss.Style) *Table func (*Table).BorderTop(v bool) *Table func (*Table).ClearRows() *Table func (*Table).Data(data Data) *Table func (*Table).FitContent() *Table func (*Table).Headers(headers ...string) *Table func (*Table).Height(h int) *Table func (*Table).Row(row ...string) *Table func (*Table).Rows(rows ...[]string) *Table func (*Table).StyleFunc(style StyleFunc) *Table func (*Table).Width(w int) *Table func (*Table).Wrap(w bool) *Table func (*Table).YOffset(o int) *Table
Package-Level Functions (total 10, in which 5 are exported)
DataToMatrix is a helper function that converts an object that implements the Data interface into a table.
DefaultStyles is a TableStyleFunc that returns a new Style with no attributes.
New returns a new Table that can be modified through different attributes. By default, a table has normal border, no styling, and no rows.
NewFilter initializes a new Filter.
NewStringData creates a new StringData with the given number of columns.
Package-Level Constants (only one, which is exported)
HeaderRow denotes the header's row index used when rendering headers. Use this value when looking to customize header styles in StyleFunc.