Seperator
A horizontal or vertical line used to visually divide UI elements in a Fyne application.
Horizontal Seperator
Section titled “Horizontal Seperator”Show Code
package main
import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/layout" "fyne.io/fyne/v2/widget")
func main() { myApp := app.New() myWindow := myApp.NewWindow("Separator")
content := container.NewVBox( widget.NewLabel("Section 1:"), widget.NewButton("Button 1", func() {}), layout.NewSpacer(),
widget.NewSeparator(), // horizontal separator
widget.NewLabel("Section 2:"), widget.NewButton("Button 2", func() {}), layout.NewSpacer(),
widget.NewSeparator(), // horizontal separator again
widget.NewLabel("Section 3:"), widget.NewButton("Button 3", func() {}), )
myWindow.SetContent(content) myWindow.Resize(fyne.NewSize(300, 200)) myWindow.ShowAndRun()}Vertical Seperator
Section titled “Vertical Seperator”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("Vertical Separator")
leftContent := container.NewVBox( widget.NewLabel("Left Section"), widget.NewButton("Button A", func() {}), )
rightContent := container.NewVBox( widget.NewLabel("Right Section"), widget.NewButton("Button B", func() {}), )
// In an HBox, the separator will be vertical content := container.NewHBox( leftContent, widget.NewSeparator(), rightContent, )
myWindow.SetContent(content) myWindow.Resize(fyne.NewSize(300, 150)) myWindow.ShowAndRun()}