Skip to content
Getting Started

Getting Started

Gift is a declarative UI toolkit for Go. You describe your interface with SwiftUI-style views, keep its data in typed state, and gift draws it on the GPU with Ebitengine. There is no browser, no WebView and no web stack. Gift focuses on desktop applications and touchscreen kiosks, particularly on Raspberry Pi 4 and 5.

func counter(ctx *gift.Context) gift.View {
	count := ctx.State("count", 0)
	n := ctx.Read(count)
	return ui.Window(ui.VStack(
		ui.Text(fmt.Sprintf("%d clicks", n)),
		ui.Button(ui.Text("+1"), func() { count.Set(count.Get() + 1) }),
	).Gap(16).Padding(24))
}

Your first app turns this function into a complete program.

How it works

  • Views are values. A view is a short-lived Go value such as ui.Text or ui.VStack. You compose views in plain Go functions and configure them with chained methods such as Gap or modifiers such as Padding. See Views and Modifiers.
  • State is typed. ctx.State creates a named, typed value that belongs to a component. ctx.Read returns its value and records that the component depends on it. See State.
  • Updates are targeted. Writing a state rebuilds only the components that read it. Gift keeps a retained tree of nodes and lays out only the parts that changed, instead of rebuilding the whole interface.
  • Rendering runs on the GPU. The backend in backend/ebiten opens the window, polls mouse, keyboard and touch input, and draws the display list with Ebitengine.
  • One goroutine owns the UI. Background work hands its result back with App.Post. See Concurrency.

Who it is for

Gift fits you if you:

  • write a desktop or kiosk application in Go and want to describe its interface in Go as well,
  • target modest hardware such as a Raspberry Pi with a touchscreen,
  • build image-heavy interfaces: gift brings virtualized galleries, asynchronous image loading and bounded resource budgets,
  • want to test your interface from Go tests, see Testing.

Gift is not the right tool if you:

  • build a web application: gift draws into a native window, not into a browser,
  • need native platform widgets: gift draws every control itself, including its own file picker,
  • need screen reader support: gift has no accessibility bridge yet.

Development status

Gift is under development. APIs may still change. 1080p at 60 Hz on a Raspberry Pi is a target, not a verified performance guarantee.

Next steps