inspector

Inserts an inspector at the applied position in the view hierarchy.

View ModifieriOS 17.0+macOS 14.0+inspector(isPresented:content:) in SwiftUI

Declaration

React
compose().inspector({
  isPresented: Binding<boolean>,
  content: ReactNode,
})
Swift
nonisolated func inspector<V>(
    isPresented: Binding<Bool>,
    @ContentBuilder content: () -> V
) -> some View
where V : View

Parameters

  • options.isPresented*Binding<boolean>

    A binding to Bool controlling the presented state.

  • options.content*ReactNode

    The inspector content.

Discussion

Apply this modifier to declare an inspector with a context-dependent presentation. For example, an inspector can present as a trailing column in a horizontally regular size class, but adapt to a sheet in a horizontally compact size class.

struct ShapeEditor: View {
    @State private var presented: Bool = false
    var body: some View {
        MyEditorView()
            .inspector(isPresented: $presented) {
                TextTraitsInspectorView()
            }
    }
}

restored by the framework.

  • Seealso: InspectorCommands for including the default inspector commands and keyboard shortcuts.

See also

More in Presentation.