Skip to content

Fyne β€” Cross-Platform GUI Toolkit for Go

Last reviewed: 2026-09-17

Fyne is an open-source, cross-platform GUI toolkit for the Go programming language. It is designed to make it easy to create native-looking graphical applications for desktop (Windows, macOS, Linux) and mobile (Android, iOS) from a single codebase.


Overview

Fyne stands out among Go GUI toolkits because it is:

  • Pure Go β€” no C/C++ bindings, no system UI frameworks required
  • Hardware-accelerated β€” renders through OpenGL
  • Material Design β€” modern flat UI by default
  • Cross-platform β€” the same code runs on desktop and mobile
  • Themeable β€” light/dark themes, custom styling
  • Internationalized β€” built-in i18n support

Topics Covered

  • Installation and module setup (go get fyne.io/fyne/v2)
  • Hello World application structure
  • Common widgets (button, label, entry, list, table)
  • Layout containers (VBox, HBox, GridWrap, Border)
  • Data binding for reactive UI
  • Canvas and custom drawing
  • Window management and lifecycle

Installation

go mod init example.com/fyneapp
go get fyne.io/fyne/v2

# For the optional fyne CLI (packaging, cross-compilation, hot reload)
go install fyne.io/tools/cmd/fyne@latest

On Linux you also need the OpenGL and X11 development headers:

sudo apt install -y gcc libgl1-mesa-dev xorg-dev

Hello World

package main

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

func main() {
    a := app.New()
    w := a.NewWindow("Hello Fyne")
    w.SetContent(widget.NewLabel("Hello World!"))
    w.ShowAndRun()
}

Core Widgets

Widget Description
widget.Label Text display
widget.Button Clickable button
widget.Entry Text input field
widget.Check Checkbox
widget.RadioGroup Radio button group
widget.Select Dropdown selector
widget.Slider Slider for numeric input
widget.ProgressBar Progress indicator
widget.List Scrollable list
widget.Table Grid table
widget.Tree Hierarchical tree view

Layout Containers

Container Behavior
container.NewVBox() Vertical stack
container.NewHBox() Horizontal stack
container.NewGridWrap(cols) Grid with wrapped items
container.NewBorder(top, bottom, left, right, center) Border layout
layout.NewGridLayout(cols) Uniform grid
layout.NewCenterLayout() Center content
layout.NewMaxLayout() Fill available space

Key Concepts

App Lifecycle

  1. app.New() β€” Create the application instance
  2. a.NewWindow(title) β€” Create a window
  3. w.SetContent(widget) β€” Set the root content
  4. w.ShowAndRun() β€” Display window and start event loop

ShowAndRun() blocks until the last window is closed; call w.Show() plus a.Run() instead when you need to run code between showing and running.

Data Binding

Fyne supports data binding for reactive UI updates:

name := binding.NewString()
name.Set("John")
entry := widget.NewEntryWithData(name)
label := widget.NewLabelWithData(name)
// Changes to entry automatically update the label

Bindings work for basic types, lists and maps, and sit at the heart of Fyne's MVVM-style patterns.

Canvas & Custom Drawing

For custom graphics, Fyne provides a canvas API:

  • canvas.NewLine(color) β€” Draw lines
  • canvas.NewCircle(color) β€” Draw circles
  • canvas.NewImageFromFile(path) β€” Display images
  • canvas.NewText(text, color) β€” Custom text with font control

Custom widgets implement the fyne.Widget interface (CreateRenderer, Layout, MinSize) when the built-in widgets and containers are not enough.


Packaging and Distribution

# Package for the current platform
fyne package -os linux   -name MyApp
fyne package -os windows -name MyApp
fyne package -os darwin  -name MyApp

# Cross-compile for a phone
fyne package -os android -appID com.example.myapp
fyne package -os ios     -appID com.example.myapp

The CLI produces a native bundle per target (desktop) or an installable package (mobile), including the app icon and metadata.


Comparison with Other Go GUI Toolkits

Toolkit Approach Platforms Complexity
Fyne Pure Go, OpenGL Desktop + Mobile Moderate
Gio Pure Go, GPU-backed Desktop + Mobile High (IMGUI)
Wails Go backend + Web UI Desktop Low
Walk Windows Win32 API Windows only Moderate
Golang-UI Bindings to Nuklear Desktop Moderate

Resources