EmptyView

A view that doesn't contain any content.

ComponentiOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+EmptyView in SwiftUI

Declaration

React
import { EmptyView } from 'swiftui-react-native';
Swift
@frozen nonisolated struct EmptyView

Initializers

One SwiftUI initializer backs <EmptyView>.

React
<EmptyView />
Swift
nonisolated init()

Takes no props.

Also takes the common view props: modifiers, style and testID.

Overview

You will rarely, if ever, need to create an EmptyView directly. Instead, EmptyView represents the absence of a view.

SwiftUI uses EmptyView in situations where a SwiftUI view type defines one or more child views with generic parameters, and allows the child views to be absent. When absent, the child view's type in the generic type parameter is EmptyView.

The following example creates an indeterminate ProgressView without a label. The ProgressView type declares two generic parameters, Label and CurrentValueLabel, for the types used by its subviews. When both subviews are absent, like they are here, the resulting type is ProgressView<EmptyView, EmptyView>, as indicated by the example's output:

let progressView = ProgressView()
print("\(type(of:progressView))")
// Prints: ProgressView<EmptyView, EmptyView>

From Apple’s SwiftUI documentation. Code samples there are Swift.

Relationships

Conforms to

  • Commands
  • CustomizableToolbarContent
  • SceneAccessoryContent
  • Swift.BitwiseCopyable
  • Swift.Copyable
  • Swift.Escapable
  • Swift.Sendable
  • Swift.SendableMetatype
  • ToolbarContent
  • View

See also

More in Views.