LavaUI docs GitHub

struct Toggle

Swift

struct Toggle

A boolean switch with an animated knob.

The value lives wherever the Binding points; the node keeps only what is needed to draw the transition. That split matters: flipping the binding from anywhere — another control, a model update, a keyboard shortcut — still animates, because configure retargets from the bound value on every reconcile rather than only from the click handler.

Sources/LavaUI/Toggle.swift:10

Constructors

init(_ label: String = "", isOn: Binding<Bool>, style: ToggleStyle = ToggleStyle(), font: UIFont? = nil, isEnabled: Bool = true)

Creates a toggle. Every parameter matches the property of the same name.

Sources/LavaUI/Toggle.swift:23

Properties

var dumpDetail: String { get }

Not documented.

Sources/LavaUI/Toggle.swift:40

var font: UIFont?

The label's font, or nil for the environment's.

Sources/LavaUI/Toggle.swift:18

var isEnabled: Bool

Whether clicks flip the switch. A disabled toggle draws in the style's disabled colours.

Sources/LavaUI/Toggle.swift:20

var isOn: Binding<Bool>

Whether the switch is on. Clicking writes the opposite value.

Sources/LavaUI/Toggle.swift:14

var label: String

Text drawn after the switch. Clicking it flips the switch too.

Sources/LavaUI/Toggle.swift:12

var resolvedFont: UIFont? { get }

The label's font: font, or the environment's when that is nil.

Sources/LavaUI/Toggle.swift:38

var style: ToggleStyle

Colours, size and timing.

Sources/LavaUI/Toggle.swift:16

Methods

func mountPrimitive() -> any AnyViewNode

Not documented.

Sources/LavaUI/Toggle.swift:44

func reconcilePrimitive(_ node: any AnyViewNode) -> any AnyViewNode

Not documented.

Sources/LavaUI/Toggle.swift:61