Skip to main content

Button

Button renders a clickable button. When the user presses it the client sends a RerunPage message, the page is re‑executed, and the call returns true for that single run. On the next run the value automatically resets to false.

Signature

pressed := ui.Button(label string, opts ...button.Option) bool

Return value

TypeMeaning
booltrue if the button was clicked since the previous execution of the page; otherwise false.

Options

HelperDescription
button.WithDisabled(true)Renders the button in a disabled (non‑clickable) state.

Examples

Basic button

if ui.Button("Refresh") {
// refresh data
}

Disabled button

ui.Button("Cannot Click", button.WithDisabled(true))

Using the returned value

clicked := ui.Button("Create")
if clicked {
if err := createResource(); err != nil {
ui.Markdown("⚠️ failed to create resource")
return err
}
}