Skip to content

Button

A native SwiftUI button with text, SF Symbol, semantic role, and press handling.

#Import

Import ui from github.com/egoist/quickgui/go/ui.

import (
	"fmt"
	"github.com/egoist/quickgui/go/native"
	"github.com/egoist/quickgui/go/ui"
)

#Usage

func SwiftUiButtonExample() *native.Node {
	return ui.SwiftUI.Host(
		ui.SwiftUIHostProps{MatchContents: true},
		func() *native.Node {
			return ui.SwiftUI.Button(ui.SwiftUIButtonProps{
				Label:       "Save",
				SystemImage: "checkmark",
				OnPress:     func(*native.Event) { fmt.Println("Saved") },
				Modifiers:   []ui.SwiftUIModifier{ui.SwiftUI.ButtonStyle("borderedProminent")},
			})
		},
	)
}

#API reference

Expand an entry for its description and complete signature. A dash means no declaration default is documented.

SwiftUI.Button

View source
ui.SwiftUI.Button(props SwiftUIButtonProps, children ...any) *native.Node
TestIDany—

Stable identifier for native automation and tests.

any
View source
Modifiersany—

Ordered SwiftUI view modifiers applied to the hosted control.

any
View source
Reffunc(*native.Node)—

Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.

func(*native.Node)
View source
Labelany—

Visible native SwiftUI control label.

any
View source
SystemImagestring—

SF Symbols name displayed with a SwiftUI button label.

string
View source
Rolestring—

Accessibility role override. Prefer the component’s built-in semantics.

string
View source
OnPressfunc(*native.Event)—

Runs when the native SwiftUI button is activated.

func(*native.Event)
View source
Targetstring—

Destination associated with this navigation or link part.

string
View source
ChildrenComponent—

Content mounted inside the component. Compound child callbacks run after the parent context exists.

Component
View source