Skip to content

SwiftUI

Enable the swift-ui crate feature. Ordinary QuickGUI components work without it.

#Host

Construct MacSwiftUiHost, sync a descriptor tree, and mount it with native_view.

let mut host = MacSwiftUiHost::new(|_id| {})?;
host.sync(&[SwiftUiButton::new(1).label("Continue").into()])?;
native_view(host.view())

#Native controls

Buttons, toggles, sliders, steppers, progress views, gauges, text and secure fields, pickers, segmented controls, date and color pickers, and popovers.

#Controlled values

let mut host = MacSwiftUiHost::new_with_control_events(
    |_id| {},
    |_id, _presented| {},
    |id, value| { /* store value for id */ },
    |_id| {},
)?;
host.sync(&[SwiftUiToggle::new(1, enabled).label("Notifications").into()])?;
native_view(host.view())

#Sizing

MacSwiftUiHost::fitting_size reports the control’s intrinsic size. Constrain the parent when you want a fixed width.

#Platform support

SwiftUI hosting requires macOS. Optional appearances such as Liquid Glass depend on the operating-system version.