Skip to main content
Empty(): Component;

Support

Usage

Conditional rendering

Use Empty() when you need to conditionally show nothing in a view hierarchy:
VStack([
    Text("Always visible"),
    showContent ? Text("Conditional content") : Empty(),
    Text("Also always visible")
])

As a placeholder during development

VStack([
    Text("Header"),
    Empty(), // TODO: Add content here
    Text("Footer")
])

With ternary expressions

const content = items.length > 0
    ? ForEach(items, (item) => Text(item))
    : Empty();

VStack([content])

In conditional logic

VStack([
    Text("Title"),
    isLoading ? ProgressView() : Empty(),
    hasError ? Text("Error occurred").foregroundStyle(Color("red")) : Empty(),
    Text("Content")
])

Notes

Empty() provides a semantic way to represent “no content” in your component tree. It’s more explicit than using null or undefined and integrates cleanly with the component system.