Hello Gophers!
I’d wish 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 personal Go code: callbacks replace it, and dxui rebuilds and reconciles the view description.
What it gives
- Construct with out cgo: each the framework and software builds help
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 could differ by platform, construct configuration, and software 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 little one home windows and a keyed, fixed-height digital record.
Strive it
git clone https://github.com/dxui-org/dxui.git
cd dxui
go run ./examples/elements
The element catalog allows you to discover controls, change their properties, and swap themes. For smaller examples, attempt the calculator or login type:
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 record with 100,000 fixed-height rows.
What the code appears to be like like
Right here’s an entire greeting type:
bundle foremost
import (
"log"
"github.com/dxui-org/dxui"
)
func foremost() {
app := dxui.NewApp(dxui.AppOptions{
Title: "Hiya dxui", Width: 480, Top: 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("Hiya, " + 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 foremost.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 methods. What would you want from dxui earlier than contemplating it for a desktop challenge?
In the event you encounter a rendering or enter problem, please embody your OS/structure, Go model, and a small copy in a github problem.
Thanks for having a look!

