Gova
Widgets

Button

Tappable button with a label and a handler.

func Button(label string, handler func()) *viewNode
func (n *viewNode) Style(s ButtonStyle) *viewNode
gova.Button("Save", func() {
    save()
})

The handler is called on the UI goroutine. If the handler does expensive work, move it to a goroutine yourself.

Styles

ButtonStyle is accepted by Style:

  • ButtonDefault (zero value)
  • ButtonPrimary
  • ButtonDestructive
gova.Button("Delete", onDelete).Style(gova.ButtonDestructive)

Do not apply OnTap to a Button

OnTap is for non-interactive views. Applying it to a Button panics with a clear message; pass the handler to Button itself.

Color

The Color modifier applies to the label text:

gova.Button("Delete", onDelete).Color(gova.Red)

Use semantic colors for theme-aware styling:

gova.Button("Delete", onDelete).Color(gova.Destructive)

On this page