Toolbar
Toolbars provide quick access to common actions using buttons and icons.
With Icons
Section titled “With Icons”Show Code
package main
import ( "fmt"
"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("Toolbar with Icons")
// Create toolbar with icons toolbar := widget.NewToolbar( widget.NewToolbarAction(theme.HomeIcon(), func() { fmt.Println("Home clicked") }), widget.NewToolbarSeparator(), widget.NewToolbarAction(theme.SearchIcon(), func() { fmt.Println("Search clicked") }), widget.NewToolbarSpacer(), widget.NewToolbarAction(theme.SettingsIcon(), func() { fmt.Println("Settings clicked") }), widget.NewToolbarAction(theme.AccountIcon(), func() { fmt.Println("Profile clicked") }), )
// Content placeholder content := widget.NewLabel("Main Content Area")
// Place toolbar at the top mainContent := container.NewBorder(toolbar, nil, nil, nil, content)
myWindow.SetContent(mainContent) myWindow.Resize(fyne.NewSize(400, 300)) myWindow.ShowAndRun()}