Table

The b.Table constructor creates a table. The b.ScrollableTable constructor creates a table in a table-container element, making the table scrollable.

ModifierAction
b.BorderedAdd borders to the table
b.StripedAdd stripes to the body rows
b.NarrowMake the cells narrower
b.HoverableAdd a hover effect on the body rows
b.FullWidthTake the whole width
ChildAction
b.OnHead(...any)Apply children to the <thead> element
b.OnBody(...any)Apply children to the <tbody> element
b.OnFoot(...any)Apply children to the <tfoot> element
b.Row(...any)Add a row to the <tbody> element, its cells are defined as <td> elements
b.HeadRow(...any)Add a row to the <thead> element, its cells are defined as <th> elements
b.FootRow(...any)Add a row to the <tfoot> element, its cells are defined as <th> elements
Anything elseApply children to the <table> element

The b.Row, b.HeadRow and b.FootRow constructors create rows, respectively for the body, head and foot of a table.

ChildAction
b.TCell(...any)Add a cell to the row, chosing its element automatically according to the row destination
b.Th(...any)Add a cell to the row, with element <th>
b.Td(...any)Add a cell to the row, with element <td>
stringAdd a cell to the row with the given string as its only content
gomponents.Nodeof type gomponents.AttributeTypeApply child to the <tr> element
gomponents.Nodeof type gomponents.ElementTypeAdd a cell to the row with the given element as its only content
Anything elseApply child to the <tr> element

The b.TCell, b.Th and b.Td element create cells with the given children as their content.

Bulma examples

Bulma-styled table are implemented with the b.Table function.

Example
Code
headFoot := []any{
	b.Abbr("Position", "Pos"),
	"Team",
	b.Abbr("Played", "Pld"),
	b.Abbr("Won", "W"),
	b.Abbr("Drawn", "D"),
	b.Abbr("Lost", "L"),
	b.Abbr("Goals for", "GF"),
	b.Abbr("Goals against", "GA"),
	b.Abbr("Goal difference", "GD"),
	b.Abbr("Points", "Pts"),
	"Qualification or relegation",
}
b.Table(
	b.HeadRow(headFoot...),
	b.FootRow(headFoot...),
	b.Row(
		b.TCell(html.Th, "1"),
		b.TCell(
			e.A(
				e.Href("https://en.wikipedia.org/wiki/Leicester_City_F.C."),
				e.TitleAttr("Leicester City F.C."),
				"Leicester City",
			),
			" ",
			e.Strong("(C)"),
		),
		"38",
		"23",
		"12",
		"3",
		"68",
		"36",
		"+32",
		"81",
		b.TCell(
			"Qualification for the ", e.A(e.Href("https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Champions_League#Group_stage"), e.TitleAttr("2016–17 UEFA Champions League"), "Champions League group stage"),
		),
	),
	b.Row(
		b.TCell(html.Th, "2"),
		e.A(e.Href("https://en.wikipedia.org/wiki/Arsenal_F.C."), e.TitleAttr("Arsenal F.C."), "Arsenal"),
		"38",
		"20",
		"11",
		"7",
		"65",
		"36",
		"+29",
		"71",
		b.TCell(
			"Qualification for the ", e.A(e.Href("https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Champions_League#Group_stage"), e.TitleAttr("2016–17 UEFA Champions League"), "Champions League group stage"),
		),
	),
	b.Row(
		b.TCell(html.Th, "3"),
		e.A(e.Href("https://en.wikipedia.org/wiki/Tottenham_Hotspur_F.C."), e.TitleAttr("Tottenham Hotspur F.C."), "Tottenham Hotspur"),
		"38",
		"19",
		"13",
		"6",
		"69",
		"35",
		"+34",
		"70",
		b.TCell(
			"Qualification for the ", e.A(e.Href("https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Champions_League#Group_stage"), e.TitleAttr("2016–17 UEFA Champions League"), "Champions League group stage"),
		),
	),
	b.Row(
		b.Selected,
		b.TCell(html.Th, "4"),
		e.A(e.Href("https://en.wikipedia.org/wiki/Manchester_City_F.C."), e.TitleAttr("Manchester City F.C."), "Manchester City"),
		"38",
		"19",
		"9",
		"10",
		"71",
		"41",
		"+30",
		"66",
		b.TCell(
			"Qualification for the ", e.A(e.Href("https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Champions_League#Play-off_round"), e.TitleAttr("2016–17 UEFA Champions League"), "Champions League play-off round"),
		),
	),
	b.Row(
		b.TCell(html.Th, "5"),
		e.A(e.Href("https://en.wikipedia.org/wiki/Manchester_United_F.C."), e.TitleAttr("Manchester United F.C."), "Manchester United"),
		"38",
		"19",
		"9",
		"10",
		"49",
		"35",
		"+14",
		"66",
		b.TCell(
			"Qualification for the ", e.A(e.Href("https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Europa_League#Group_stage"), e.TitleAttr("2016–17 UEFA Europa League"), "Europa League group stage"),
		),
	),
	b.Row(
		b.TCell(html.Th, "6"),
		e.A(e.Href("https://en.wikipedia.org/wiki/Southampton_F.C."), e.TitleAttr("Southampton F.C."), "Southampton"),
		"38",
		"18",
		"9",
		"11",
		"59",
		"41",
		"+18",
		"63",
		b.TCell(
			"Qualification for the ", e.A(e.Href("https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Europa_League#Group_stage"), e.TitleAttr("2016–17 UEFA Europa League"), "Europa League group stage"),
		),
	),
	b.Row(
		b.TCell(html.Th, "7"),
		e.A(e.Href("https://en.wikipedia.org/wiki/West_Ham_United_F.C."), e.TitleAttr("West Ham United F.C."), "West Ham United"),
		"38",
		"16",
		"14",
		"8",
		"65",
		"51",
		"+14",
		"62",
		b.TCell(
			"Qualification for the ", e.A(e.Href("https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Europa_League#Third_qualifying_round"), e.TitleAttr("2016–17 UEFA Europa League"), "Europa League third qualifying round"),
		),
	),
	b.Row(
		b.TCell(html.Th, "8"),
		e.A(e.Href("https://en.wikipedia.org/wiki/Liverpool_F.C."), e.TitleAttr("Liverpool F.C."), "Liverpool"),
		"38",
		"16",
		"12",
		"10",
		"63",
		"50",
		"+13",
		"60",
		"",
	),
	b.Row(
		b.TCell(html.Th, "9"),
		e.A(e.Href("https://en.wikipedia.org/wiki/Stoke_City_F.C."), e.TitleAttr("Stoke City F.C."), "Stoke City"),
		"38",
		"14",
		"9",
		"15",
		"41",
		"55",
		b.TCell("-14"),
		"51",
		"",
	),
	b.Row(
		b.TCell(html.Th, "10"),
		e.A(e.Href("https://en.wikipedia.org/wiki/Chelsea_F.C."), e.TitleAttr("Chelsea F.C."), "Chelsea"),
		"38",
		"12",
		"14",
		"12",
		"59",
		"53",
		"+6",
		"50",
		"",
	),
	b.Row(
		b.TCell(html.Th, "11"),
		e.A(e.Href("https://en.wikipedia.org/wiki/Everton_F.C."), e.TitleAttr("Everton F.C."), "Everton"),
		"38",
		"11",
		"14",
		"13",
		"59",
		"55",
		"+4",
		"47",
		"",
	),
	b.Row(
		b.TCell(html.Th, "12"),
		e.A(e.Href("https://en.wikipedia.org/wiki/Swansea_City_A.F.C."), e.TitleAttr("Swansea City A.F.C."), "Swansea City"),
		"38",
		"12",
		"11",
		"15",
		"42",
		"52",
		"-10",
		"47",
		"",
	),
	b.Row(
		b.TCell(html.Th, "13"),
		e.A(e.Href("https://en.wikipedia.org/wiki/Watford_F.C."), e.TitleAttr("Watford F.C."), "Watford"),
		"38",
		"12",
		"9",
		"17",
		"40",
		"50",
		"-10",
		"45",
		"",
	),
	b.Row(
		b.TCell(html.Th, "14"),
		e.A(e.Href("https://en.wikipedia.org/wiki/West_Bromwich_Albion_F.C."), e.TitleAttr("West Bromwich Albion F.C."), "West Bromwich Albion"),
		"38",
		"10",
		"13",
		"15",
		"34",
		"48",
		"-14",
		"43",
		"",
	),
	b.Row(
		b.TCell(html.Th, "15"),
		e.A(e.Href("https://en.wikipedia.org/wiki/Crystal_Palace_F.C."), e.TitleAttr("Crystal Palace F.C."), "Crystal Palace"),
		"38",
		"11",
		"9",
		"18",
		"39",
		"51",
		"-12",
		"42",
		"",
	),
	b.Row(
		b.TCell(html.Th, "16"),
		e.A(e.Href("https://en.wikipedia.org/wiki/A.F.C._Bournemouth"), e.TitleAttr("A.F.C. Bournemouth"), "AFC Bournemouth"),
		"38",
		"11",
		"9",
		"18",
		"45",
		"67",
		"-22",
		"42",
		"",
	),
	b.Row(
		b.TCell(html.Th, "17"),
		e.A(e.Href("https://en.wikipedia.org/wiki/Sunderland_A.F.C."), e.TitleAttr("Sunderland A.F.C."), "Sunderland"),
		"38",
		"9",
		"12",
		"17",
		"48",
		"62",
		"-14",
		"39",
		"",
	),
	b.Row(
		b.TCell(html.Th, "18"),
		b.TCell(
			e.A(
				e.Href("https://en.wikipedia.org/wiki/Newcastle_United_F.C."),
				e.TitleAttr("Newcastle United F.C."), "Newcastle United",
			),
			" ",
			e.Strong("(R)"),
		),
		"38",
		"9",
		"10",
		"19",
		"44",
		"65",
		"-21",
		"37",
		b.TCell(
			"Relegation to the ", e.A(e.Href("https://en.wikipedia.org/wiki/2016%E2%80%9317_Football_League_Championship"), e.TitleAttr("2016–17 Football League Championship"), "Football League Championship"),
		),
	),
	b.Row(
		b.TCell(html.Th, "19"),
		b.TCell(
			e.A(
				e.Href("https://en.wikipedia.org/wiki/Norwich_City_F.C."),
				e.TitleAttr("Norwich City F.C."),
				"Norwich City",
			),
			" ",
			e.Strong("(R)"),
		),
		"38",
		"9",
		"7",
		"22",
		"39",
		"67",
		"-28",
		"34",
		b.TCell(
			"Relegation to the ", e.A(e.Href("https://en.wikipedia.org/wiki/2016%E2%80%9317_Football_League_Championship"), e.TitleAttr("2016–17 Football League Championship"), "Football League Championship"),
		),
	),
	b.Row(
		b.TCell(html.Th, "20"),
		b.TCell(
			e.A(
				e.Href("https://en.wikipedia.org/wiki/Aston_Villa_F.C."),
				e.TitleAttr("Aston Villa F.C."),
				"Aston Villa",
			),
			" ",
			e.Strong("(R)"),
		),
		"38",
		"3",
		"8",
		"27",
		"27",
		"76",
		"-49",
		"17",
		b.TCell(
			"Relegation to the ", e.A(e.Href("https://en.wikipedia.org/wiki/2016%E2%80%9317_Football_League_Championship"), e.TitleAttr("2016–17 Football League Championship"), "Football League Championship"),
		),
	),
)
ResultHTML
PosTeamPldWDLGFGAGDPtsQualification or relegation
1Leicester City (C)38231236836+3281Qualification for the Champions League group stage
2Arsenal38201176536+2971Qualification for the Champions League group stage
3Tottenham Hotspur38191366935+3470Qualification for the Champions League group stage
4Manchester City38199107141+3066Qualification for the Champions League play-off round
5Manchester United38199104935+1466Qualification for the Europa League group stage
6Southampton38189115941+1863Qualification for the Europa League group stage
7West Ham United38161486551+1462Qualification for the Europa League third qualifying round
8Liverpool381612106350+1360
9Stoke City38149154155-1451
10Chelsea381214125953+650
11Everton381114135955+447
12Swansea City381211154252-1047
13Watford38129174050-1045
14West Bromwich Albion381013153448-1443
15Crystal Palace38119183951-1242
16AFC Bournemouth38119184567-2242
17Sunderland38912174862-1439
18Newcastle United (R)38910194465-2137Relegation to the Football League Championship
19Norwich City (R)3897223967-2834Relegation to the Football League Championship
20Aston Villa (R)3838272776-4917Relegation to the Football League Championship
PosTeamPldWDLGFGAGDPtsQualification or relegation

Colors

Example
Code
b.Table(
	b.Bordered,
	b.Row(b.TCell(html.Th, b.Link, "Link th cell"), "Two", b.TCell(b.Link, "Link td cell"), "Four", "Five"),
	b.Row(b.Link, b.TCell(html.Th, "Link row"), "Two", "Three", "Four", "Five"),
	b.Row(b.TCell(html.Th, b.Primary, "Primary th cell"), "Two", b.TCell(b.Primary, "Primary td cell"), "Four", "Five"),
	b.Row(b.Primary, b.TCell(html.Th, "Primary row"), "Two", "Three", "Four", "Five"),
	b.Row(b.TCell(html.Th, b.Info, "Info th cell"), "Two", b.TCell(b.Info, "Info td cell"), "Four", "Five"),
	b.Row(b.Info, b.TCell(html.Th, "Info row"), "Two", "Three", "Four", "Five"),
	b.Row(b.TCell(html.Th, b.Success, "Success th cell"), "Two", b.TCell(b.Success, "Success td cell"), "Four", "Five"),
	b.Row(b.Success, b.TCell(html.Th, "Success row"), "Two", "Three", "Four", "Five"),
	b.Row(b.TCell(html.Th, b.Warning, "Warning th cell"), "Two", b.TCell(b.Warning, "Warning td cell"), "Four", "Five"),
	b.Row(b.Warning, b.TCell(html.Th, "Warning row"), "Two", "Three", "Four", "Five"),
	b.Row(b.TCell(html.Th, b.Danger, "Danger th cell"), "Two", b.TCell(b.Danger, "Danger td cell"), "Four", "Five"),
	b.Row(b.Danger, b.TCell(html.Th, "Danger row"), "Two", "Three", "Four", "Five"),
)
ResultHTML
TwoFourFive
Primary th cellTwoPrimary td cellFourFive
Primary rowTwoThreeFourFive
Info th cellTwoInfo td cellFourFive
Info rowTwoThreeFourFive
Success th cellTwoSuccess td cellFourFive
Success rowTwoThreeFourFive
Warning th cellTwoWarning td cellFourFive
Warning rowTwoThreeFourFive
Danger th cellTwoDanger td cellFourFive
Danger rowTwoThreeFourFive

Modifiers

Example
Code
b.Table(
	b.Bordered,
	b.HeadRow("One", "Two"),
	b.Row("Three", "Four"),
)
ResultHTML
OneTwo
ThreeFour
Example
Code
b.Table(
	b.Striped,
	b.HeadRow("One", "Two"),
	b.Row("Three", "Four"),
	b.Row("Five", "Six"),
	b.Row("Seven", "Eight"),
	b.Row("Nine", "Ten"),
	b.Row("Eleven", "Twelve"),
)
ResultHTML
OneTwo
ThreeFour
FiveSix
SevenEight
NineTen
ElevenTwelve
Example
Code
b.Table(
	b.Narrow,
	b.HeadRow("One", "Two"),
	b.Row("Three", "Four"),
	b.Row("Five", "Six"),
	b.Row("Seven", "Eight"),
	b.Row("Nine", "Ten"),
	b.Row("Eleven", "Twelve"),
)
ResultHTML
OneTwo
ThreeFour
FiveSix
SevenEight
NineTen
ElevenTwelve
Example
Code
b.Table(
	b.Hoverable,
	b.HeadRow("One", "Two"),
	b.Row("Three", "Four"),
	b.Row("Five", "Six"),
	b.Row("Seven", "Eight"),
	b.Row("Nine", "Ten"),
	b.Row("Eleven", "Twelve"),
)
ResultHTML
OneTwo
ThreeFour
FiveSix
SevenEight
NineTen
ElevenTwelve
Example
Code
b.Table(
	b.FullWidth,
	b.HeadRow("One", "Two"),
	b.Row("Three", "Four"),
	b.Row("Five", "Six"),
	b.Row("Seven", "Eight"),
	b.Row("Nine", "Ten"),
	b.Row("Eleven", "Twelve"),
)
ResultHTML
OneTwo
ThreeFour
FiveSix
SevenEight
NineTen
ElevenTwelve
Example
Code
b.Table(
	b.Bordered,
	b.Striped,
	b.Narrow,
	b.Hoverable,
	b.FullWidth,
	b.HeadRow("One", "Two"),
	b.Row("Three", "Four"),
	b.Row("Five", "Six"),
	b.Row("Seven", "Eight"),
	b.Row("Nine", "Ten"),
	b.Row("Eleven", "Twelve"),
)
ResultHTML
OneTwo
ThreeFour
FiveSix
SevenEight
NineTen
ElevenTwelve

Table container

Example
ResultHTML
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
2468101214161820222426283032343638404244464850525456586062646668707274767880828486889092949698100102104106108110112114116118120122124126128130132134136138140142144146148150152154156158160162164166168170172174176178180182184186188190192194196198200
369121518212427303336394245485154576063666972757881848790939699102105108111114117120123126129132135138141144147150153156159162165168171174177180183186189192195198201204207210213216219222225228231234237240243246249252255258261264267270273276279282285288291294297300
4812162024283236404448525660646872768084889296100104108112116120124128132136140144148152156160164168172176180184188192196200204208212216220224228232236240244248252256260264268272276280284288292296300304308312316320324328332336340344348352356360364368372376380384388392396400
5101520253035404550556065707580859095100105110115120125130135140145150155160165170175180185190195200205210215220225230235240245250255260265270275280285290295300305310315320325330335340345350355360365370375380385390395400405410415420425430435440445450455460465470475480485490495500
Code
b.ScrollableTable(
	// Your table content
)