Skip to content

Toggle

A toggle is a switch for settings which take effect immediately, e.g. enabling notifications. For values which are submitted later, use a Checkbox. The toggle has no label; for a labeled toggle in forms, use the Toggle Field.

Toggle

enabled := core.AutoState[bool](wnd).Init(func() bool { return true })

HStack(
	Toggle(enabled.Get()).InputChecked(enabled),
	Toggle(false),
	Toggle(true).Disabled(true),
).Gap(L16)

Constructors

ConstructorDescription
func Toggle(checked bool) TToggleCreates a toggle with the given value.

Methods

MethodDescription
Disabled(disabled bool) TToggleDisabled enables or disables interaction with the toggle.
ID(id string) TToggleID sets the ID of the toggle.
InputChecked(input *core.State[bool]) TToggleInputChecked binds the toggle to an external boolean state for two-way data binding.
Visible(v bool) TToggleVisible controls the visibility of the toggle; false hides it from the UI.

Related