Skip to content

Toggle

A controlled native SwiftUI on/off switch.

#Import

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

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

#Usage

func SwiftUiToggleExample() *native.Node {
	on, setOn := ui.CreateSignal(true)
	return ui.SwiftUI.Host(
		ui.SwiftUIHostProps{MatchContents: true},
		func() *native.Node {
			return ui.SwiftUI.Toggle(ui.SwiftUIToggleProps{
				IsOn:         on,
				Label:        "Notifications",
				OnIsOnChange: func(next bool, _ *native.Event) { setOn(next) },
			})
		},
	)
}

#API reference

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

SwiftUI.Toggle

View source
ui.SwiftUI.Toggle(props SwiftUIToggleProps) *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
IsOnany—

Controlled SwiftUI toggle value.

any
View source
Labelany—

Visible native SwiftUI control label.

any
View source
OnIsOnChangefunc(bool, *native.Event)—

Reports the value accepted by the native SwiftUI toggle.

func(bool, *native.Event)
View source