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. Software state stays in your personal Go code: callbacks replace it, and dxui rebuilds and reconciles the view description.
What it affords
- 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 fluctuate by platform, construct configuration, and software complexity.
- Declarative UI in Go: compose layouts and controls utilizing Go varieties, features, 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 little one home windows and a keyed, fixed-height digital listing.
Attempt it
git clone https://github.com/dxui-org/dxui.git
cd dxui
go run ./examples/elements
The part catalog helps you to discover controls, change their properties, and change 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 listing with 100,000 fixed-height rows.
What the code seems like
Right here’s an entire greeting type:
package deal foremost
import (
"log"
"github.com/dxui-org/dxui"
)
func foremost() {
app := dxui.NewApp(dxui.AppOptions{
Title: "Good day dxui", Width: 480, Top: 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("Good day, " + 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 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 case 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!

