Hello Gophers!
I’d prefer to share dxui, an open-source, MIT-licensed framework for constructing desktop UIs in Go for macOS, Home windows, and Linux.
With dxui, you describe your interface in Go utilizing typed props and callbacks. Utility state stays in your individual Go code: callbacks replace it, and dxui rebuilds and reconciles the view description.
What it affords
- Construct with out cgo: each the framework and utility builds assist
CGO_ENABLED=0. - Small footprint: in my measurements, the hello-dxui instance produces a 7 MB binary and makes use of 22 MB of reminiscence. Outcomes might differ by platform, construct configuration, and utility complexity.
- Declarative UI in Go: compose layouts and controls utilizing Go sorts, capabilities, and callbacks.
- On-demand rendering: an event- and deadline-driven loop waits when idle.
- On a regular basis controls: inputs, buttons, selects, menus, tabs, overlays, and extra.
- Styling and themes: typed theme tokens, runtime mild/darkish switching, rounded corners, shadows, and interplay states.
- A number of home windows and lengthy lists: impartial native youngster home windows and a keyed, fixed-height digital listing.
Strive it
git clone https://github.com/dxui-org/dxui.git
cd dxui
go run ./examples/elements
The element catalog enables you to discover controls, change their properties, and swap themes. For smaller examples, attempt the calculator or login kind:
go run ./examples/calc
go run ./examples/login
There are additionally examples for a number of home windows, textual content rendering, layouts, and a digital listing with 100,000 fixed-height rows.
What the code seems to be like
Right here’s a whole greeting kind:
package deal principal
import (
"log"
"github.com/dxui-org/dxui"
)
func principal() {
app := dxui.NewApp(dxui.AppOptions{
Title: "Howdy dxui", Width: 480, Peak: 240,
})
title := ""
root := func() dxui.View {
return dxui.Field(dxui.BoxProps{
Model: dxui.Model{Padding: dxui.Padding(24)},
Hole: 12,
},
dxui.Label("What's your title?"),
dxui.Enter(dxui.InputProps{
Key: "title", Worth: title, Placeholder: "Your title",
OnChange: dxui.Assign(&title),
}),
dxui.Label("Howdy, " + title + "!"),
dxui.TextButton(dxui.ButtonProps{OnPress: app.Shut}, "Shut"),
)
}
if err := app.Run(root); err != nil {
log.Deadly(err)
}
}
To run this individually, create a brand new listing, run go mod init instance.com/hello-dxui and go get github.com/dxui-org/dxui, then save the code as principal.go and run go run ..
I’d love suggestions from different Go builders, particularly on the API and your expertise operating the examples on totally different working programs. What would you want from dxui earlier than contemplating it for a desktop venture?
For those who encounter a rendering or enter challenge, please embrace your OS/structure, Go model, and a small copy in a github challenge.
Thanks for looking!

