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. Software state stays in your individual Go code: callbacks replace it, and dxui rebuilds and reconciles the view description.
What it provides
- 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 might range 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 gentle/darkish switching, rounded corners, shadows, and interplay states.
- A number of home windows and lengthy lists: unbiased native youngster home windows and a keyed, fixed-height digital checklist.
Attempt it
git clone https://github.com/dxui-org/dxui.git
cd dxui
go run ./examples/parts
The part 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 checklist with 100,000 fixed-height rows.
What the code appears to be like like
Right here’s an entire greeting type:
package deal important
import (
"log"
"github.com/dxui-org/dxui"
)
func important() {
app := dxui.NewApp(dxui.AppOptions{
Title: "Whats up dxui", Width: 480, Peak: 240,
})
identify := ""
root := func() dxui.View {
return dxui.Field(dxui.BoxProps{
Type: dxui.Type{Padding: dxui.Padding(24)},
Hole: 12,
},
dxui.Label("What's your identify?"),
dxui.Enter(dxui.InputProps{
Key: "identify", Worth: identify, Placeholder: "Your identify",
OnChange: dxui.Assign(&identify),
}),
dxui.Label("Whats up, " + identify + "!"),
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 important.go and run go run ..
I’d love suggestions from different Go builders, particularly on the API and your expertise operating the examples on completely different working techniques. What would you want from dxui earlier than contemplating it for a desktop mission?
In case you encounter a rendering or enter subject, please embrace your OS/structure, Go model, and a small copy in a github subject.
Thanks for looking!

