Color Dialog
A dialog that allows users to pick a color from a palette or enter custom color values in a Fyne application.
Color Picker
Section titled “Color Picker”Show Code
package main
import ( "fmt" "image/color"
"fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/dialog" "fyne.io/fyne/v2/widget")
func main() { a := app.NewWithID("com.example.color") w := a.NewWindow("Color Dialog")
// Label to show the selected color colorPreview := canvas.NewRectangle(color.White) colorPreview.SetMinSize(fyne.NewSize(100, 100))
// Button to open color dialog btn := widget.NewButton("Pick Color", func() { dialog.NewColorPicker("Choose a Color", "Pick your favorite color", func(c color.Color) { if c != nil { colorPreview.FillColor = c colorPreview.Refresh() fmt.Println("Selected color:", c) } }, w).Show() })
// Layout w.SetContent(container.NewVBox( btn, colorPreview, ))
w.Resize(fyne.NewSize(300, 200)) w.ShowAndRun()}