Documentation ¶
Overview ¶
Package table implements tables.
templ: version: v0.2.793
Index ¶
Examples ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func C ¶
Example ¶
package main import ( "context" "os" "github.com/a-h/templ" "github.com/jfbus/templui/components/button" "github.com/jfbus/templui/components/style" "github.com/jfbus/templui/components/table" "github.com/jfbus/templui/components/table/cell" "github.com/jfbus/templui/components/table/row" ) func main() { c := table.C(table.D{ Style: table.StyleStripedRows, Header: &row.D{ Cells: []string{"Email", "Name", "Status", ""}, }, Rows: []row.D{{ Cells: []any{ "John Doe", "john.doe@example.com", "active", cell.D{ Content: button.C(button.D{ Label: "disable", Attributes: templ.Attributes{ "hx-delete": "/users/1", }, }), }, }, }}, CustomStyle: style.Custom{ "table/cell": style.D{ style.Set("text-center"), }, }, }) _ = c.Render(context.TODO(), os.Stdout) }
Output:
Types ¶
type D ¶
type D struct { // Style defines the table style. Style style.Style // Header defines an optional header row (thead). //playground:import:github.com/jfbus/templui/components/table/row //playground:default:&row.D{Cells: []string{"Name", "Description", ""}} Header *row.D // Rows defines the body rows (tbody). //playground:default:[]row.D{{Cells: []string{"Lorem", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus.", ""}},{Cells: []string{"Ipsum", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus.", ""}},{Cells: []string{"Dolor", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus.", ""}}} Rows []row.D Footer *row.D // CustomStyle defines a custom style. // style.Custom{ // "table": style.D{style.Add("...")}, // "table/header": style.D{style.Add("...")}, // "table/row": style.D{style.Add("...")}, // "table/cell": style.D{style.Add("...")}, // "table/footer": style.D{style.Add("...")}, // } CustomStyle style.Custom }
D is the table definition.
Click to show internal directories.
Click to hide internal directories.