Skip to content

App Tabs

AppTabs provide a tabbed interface in Fyne, allowing users to switch between multiple views within the same window.

Show Code
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
func main() {
myApp := app.New()
myWindow := myApp.NewWindow("App Tabs")
// Create tabs
tabs := container.NewAppTabs(
container.NewTabItem("Home", widget.NewLabel("Welcome to the Home Tab")),
container.NewTabItem("Settings", widget.NewLabel("Adjust your preferences here")),
container.NewTabItem("Profile", widget.NewLabel("This is your profile information")),
)
// tab position
tabs.SetTabLocation(container.TabLocationTop)
myWindow.SetContent(tabs)
myWindow.Resize(fyne.NewSize(400, 300))
myWindow.ShowAndRun()
}
Show Code
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
func main() {
myApp := app.New()
myWindow := myApp.NewWindow("Tabs With Icons")
// Create tabs
tabs := container.NewAppTabs(
container.NewTabItemWithIcon("Home", theme.HomeIcon(), widget.NewLabel("Welcome to the Home Tab")),
container.NewTabItemWithIcon("Settings", theme.SettingsIcon(), widget.NewLabel("Adjust your preferences here")),
container.NewTabItemWithIcon("Profile", theme.AccountIcon(), widget.NewLabel("This is your profile information")),
)
// tab position
tabs.SetTabLocation(container.TabLocationTop)
myWindow.SetContent(tabs)
myWindow.Resize(fyne.NewSize(400, 300))
myWindow.ShowAndRun()
}