A cross-platform dialog library for Gio applications, providing zenity-like functionality with native Go implementation.
- Cross-Platform: Works on Windows, macOS, and Linux
- Native Gio Integration: Built specifically for Gio applications
- Multiple Dialog Types: Text input, single-select, and base dialogs
- Scrollable Lists: Selection dialogs support scrolling for large option lists
- Styled Input Fields: Professional-looking input fields with borders and focus highlighting
- Keyboard Shortcuts: Support for Enter (confirm) and Escape (cancel)
- Validation Support: Optional input validation for text dialogs
- Custom Entries: Allow custom input in selection dialogs
go get github.com/gesellix/gioui-dialog
package main
import (
"fmt"
"log"
"github.com/gesellix/gioui-dialog/pkg/dialog"
)
func main() {
// Text input dialog
result, canceled, err := dialog.PromptInput(dialog.InputDialogOptions{
Title: "User Input",
Label: "Enter your name:",
Description: "Please provide your full name",
DefaultText: "John Doe",
})
if err != nil {
log.Fatal(err)
}
if !canceled {
fmt.Printf("Hello, %s!\n", result)
}
}
Prompts the user for text input with optional validation.
result, canceled, err := dialog.PromptInput(dialog.InputDialogOptions{
Title: "API Key",
Label: "Enter your API key",
Description: "This will be stored securely",
DefaultText: "abcd-1234",
Validate: func(s string) error {
if len(s) < 4 {
return fmt.Errorf("API key must be at least 4 characters")
}
return nil
},
})
Allows users to select one option from a list, with optional custom entry.
selected, canceled, err := dialog.PromptSelect(dialog.SelectDialogOptions{
Title: "Choose Language",
Label: "Select programming language",
Description: "Choose your favorite language to install",
Choices: []string{"Go", "Rust", "Python", "Java", "JavaScript"},
DefaultSelection: "Go",
AllowCustomEntry: true,
})
Simple confirmation dialog with OK/Cancel buttons.
confirmed, canceled, err := dialog.PromptBase(dialog.BaseDialogOptions{
Title: "Confirmation",
Label: "Are you sure?",
Description: "This action cannot be undone.",
})
Field | Type | Description |
---|---|---|
Title |
string |
Window title |
Label |
string |
Main prompt text |
Description |
string |
Additional help text (optional) |
DefaultText |
string |
Pre-filled text in input field |
Validate |
func(string) error |
Input validation function (optional) |
Field | Type | Description |
---|---|---|
Title |
string |
Window title |
Label |
string |
Main prompt text |
Description |
string |
Additional help text (optional) |
Choices |
[]string |
Available options to select from |
DefaultSelection |
string |
Pre-selected option |
AllowCustomEntry |
bool |
Allow user to enter custom values |
Field | Type | Description |
---|---|---|
Title |
string |
Window title |
Label |
string |
Main prompt text |
Description |
string |
Additional help text (optional) |
Run the included demo to see all dialog types in action:
go run ./cmd/gioui-dialog
The demo application provides buttons to test each dialog type and displays the results.
- Enter: Confirm/OK (in text dialogs, also works when input field has focus)
- Escape: Cancel/Close dialog
go build ./cmd/gioui-dialog
.
├── cmd/gioui-dialog/ # Demo application
│ └── main.go
├── pkg/dialog/ # Public API
│ └── dialog.go
├── internal/dialog/ # Internal implementations
│ ├── base.go # Base dialog
│ ├── input.go # Text input dialog
│ └── select.go # Single-select dialog
├── SPEC.md # Technical specification
├── README.md # This file
├── LICENSE # MIT License
└── go.mod # Go module definition
- Go 1.24 or later
- Gio v0.8.0 or later
- Windows: Full support
- macOS: Full support
- Linux: Full support (requires X11 or Wayland)
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.