TabContainer

The tab container widget is used to allow the user to switch between different content panels. Tabs are either just text or text and icon. It is recommended not to mix some tabs having icons and some without. A tab container is created using widget.NewTabContainer(...) and passing widget.TabItem items (that can be created using widget.NewTabItem(...)).

The tab container can be configured by setting the location of tabs, one of widget.TabLocationTop, widget.TabLocationBottom, widget.TabLocationLeading and widget.TabLocationTrailing. The default location is top.

When loaded on a mobile device the tab location may be ignored. In a portrait orientation a leading or trailing position will be changed to bottom. When in landscape then top or bottom positions will be moved to leading.

Example Code

            
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package main

import (
	"fyne.io/fyne/app"
	//"fyne.io/fyne/theme"
	"fyne.io/fyne/widget"
)

func main() {
	myApp := app.New()
	myWindow := myApp.NewWindow("TabContainer Widget")

	tabs := widget.NewTabContainer(
		widget.NewTabItem("Tab 1", widget.NewLabel("Hello")),
		widget.NewTabItem("Tab 2", widget.NewLabel("World!")))

	//tabs.Append(widget.NewTabItemWithIcon("Home", theme.HomeIcon(), widget.NewLabel("Home tab")))

	tabs.SetTabLocation(widget.TabLocationLeading)

	myWindow.SetContent(tabs)
	myWindow.ShowAndRun()
}