Search
Loading...
Skip to content

Hide Elements

Control UI visibility through complete component hiding or selective item removal across editor components.

We configure UI element visibility through two distinct approaches: hiding entire components or removing specific items while keeping containers visible.

Editor with hidden dock

Explore the complete code sample on GitHub.

Understanding Hide vs. Remove#

CE.SDK iOS provides two approaches for controlling UI element visibility:

Hiding Components removes the entire UI component from the view hierarchy. We provide an empty closure to .imgly.dockItems, which hides the dock container and background completely. This capability is dock-specific—other components don’t support full hiding.

Removing Items selectively removes individual buttons while keeping the component container visible. We use .imgly.modify[Component]Items modifiers with items.remove(id:) to remove specific buttons from any component.

Key Distinction:

ApproachMethodResultComponents
Hide Component.imgly.dockItems { _ in }Entire container hiddenDock only
Remove Items.modify[Component]Items { _, items in items.remove(id:) }Container visible, items removedAll components

Why the Difference?

The dock supports complete hiding because it’s a self-contained toolbar. Other components (Navigation Bar, Canvas Menu, Inspector Bar) use SwiftUI layout patterns where the container always renders—removing items affects only the buttons, not the component structure.

Hiding the Dock#

We hide the dock completely by providing an empty closure to .imgly.dockItems:

// To hide the dock completely, provide an empty closure to .imgly.dockItems
// The dock is the only UI component that fully hides when given no items
var editorWithHiddenDock: some View {
DesignEditor(settings)
.imgly.dockItems { _ in
// Empty - dock will be completely hidden
}
}

Key Points:

  • Only UI component supporting complete container hiding
  • Background and all content removed from view hierarchy
  • Useful for minimal or focused editing modes
  • Cannot be applied to other components (Navigation Bar, Canvas Menu, Inspector Bar)

When to Hide the Dock:

  • Distraction-free editing experiences
  • Custom toolbar implementations
  • Minimal interfaces for specific workflows
  • Full-screen canvas-focused modes

Removing Specific Items#

We remove individual items from any component using .modify[Component]Items with items.remove(id:):

// To remove specific items from any component, use the modify variants
// The component container remains visible, only the specified items are removed
var editorWithRemovedItems: some View {
DesignEditor(settings)
.imgly.modifyDockItems { _, items in
items.remove(id: Dock.Buttons.ID.elementsLibrary)
items.remove(id: Dock.Buttons.ID.shapesLibrary)
}
.imgly.modifyNavigationBarItems { _, items in
items.remove(id: NavigationBar.Buttons.ID.undo)
items.remove(id: NavigationBar.Buttons.ID.redo)
}
}

Key Points:

  • Container remains visible, only specified buttons removed
  • Works across all components (Dock, Navigation Bar, Canvas Menu, Inspector Bar)
  • Use component-specific ID enums (e.g., Dock.Buttons.ID.*)
  • Multiple items can be removed in sequence

Removing from Dock#

.imgly.modifyDockItems { _, items in
items.remove(id: Dock.Buttons.ID.elementsLibrary)
items.remove(id: Dock.Buttons.ID.shapesLibrary)
}

We use Dock.Buttons.ID.* to reference dock buttons for removal.

Removing from Navigation Bar#

.imgly.modifyNavigationBarItems { _, items in
items.remove(id: NavigationBar.Buttons.ID.undo)
items.remove(id: NavigationBar.Buttons.ID.redo)
}

We use NavigationBar.Buttons.ID.* to reference navigation bar buttons for removal.

Removing from Other Components#

The same pattern applies to all components:

// Canvas Menu
.imgly.modifyCanvasMenuItems { _, items in
items.remove(id: CanvasMenu.Buttons.ID.bringForward)
items.remove(id: CanvasMenu.Buttons.ID.sendBackward)
}
// Inspector Bar
.imgly.modifyInspectorBarItems { _, items in
items.remove(id: InspectorBar.Buttons.ID.crop)
items.remove(id: InspectorBar.Buttons.ID.filter)
}

Common Use Cases#

Hide Dock for Distraction-Free Editing#

We hide the dock completely to create focused editing experiences:

DesignEditor(settings)
.imgly.dockItems { _ in
// Empty - dock hidden
}

Use when: Maximizing canvas space, creating minimal interfaces, or implementing custom toolbars.

Remove Specific Items to Simplify Interface#

We remove individual buttons to streamline the interface for specific workflows:

DesignEditor(settings)
.imgly.modifyDockItems { _, items in
// Keep only essential tools
items.remove(id: Dock.Buttons.ID.stickersLibrary)
items.remove(id: Dock.Buttons.ID.shapesLibrary)
}

Use when: Limiting functionality, creating beginner-friendly interfaces, or enforcing workflow constraints.

Limit Navigation Options#

We remove navigation buttons to control user flow:

DesignEditor(settings)
.imgly.modifyNavigationBarItems { _, items in
// Remove undo/redo for simpler interface
items.remove(id: NavigationBar.Buttons.ID.undo)
items.remove(id: NavigationBar.Buttons.ID.redo)
}

Use when: Guided workflows, simplified editing modes, or workflow enforcement.

How Hide and Remove Interact#

Hide and Remove are Independent:

  • Hiding the dock (.imgly.dockItems { _ in }) affects the entire component
  • Removing items (.imgly.modifyDockItems { _, items in }) affects individual buttons
  • We can use both: hide dock, remove items from other components

Example Combining Both:

DesignEditor(settings)
.imgly.dockItems { _ in
// Hide dock completely
}
.imgly.modifyNavigationBarItems { _, items in
// Remove specific navigation buttons
items.remove(id: NavigationBar.Buttons.ID.undo)
}

Troubleshooting#

Dock Not Hiding#

Symptom: Dock still visible after providing empty closure

Causes:

  • Using .modifyDockItems instead of .dockItems
  • Closure not actually empty (contains code)

Solutions:

// ✅ Correct - hides dock completely
.imgly.dockItems { _ in
// Empty - dock hidden
}
// ❌ Wrong - modifies items but doesn't hide container
.imgly.modifyDockItems { _, items in
// Even if empty, container remains visible
}

Other Components Not Hiding#

Symptom: Navigation Bar, Canvas Menu, or Inspector Bar still visible with empty closures

Cause: Only dock supports complete container hiding

Solution:

// ❌ Won't hide navigation bar container
.imgly.navigationBarItems { _ in }
// ✅ Remove all items instead
.imgly.modifyNavigationBarItems { _, items in
items.remove(id: NavigationBar.Buttons.ID.undo)
items.remove(id: NavigationBar.Buttons.ID.redo)
items.remove(id: NavigationBar.Buttons.ID.export)
items.remove(id: NavigationBar.Buttons.ID.closeEditor)
}

Items Still Visible After Remove#

Symptom: Button still appears after calling items.remove(id:)

Causes:

  • Wrong component ID enum (e.g., using Dock.Buttons.ID in navigation bar)
  • Typo in ID
  • Modify closure not being called

Solutions:

// ✅ Use correct component's ID enum
.imgly.modifyDockItems { _, items in
items.remove(id: Dock.Buttons.ID.elementsLibrary) // Dock ID for dock
}
.imgly.modifyNavigationBarItems { _, items in
items.remove(id: NavigationBar.Buttons.ID.undo) // Navbar ID for navbar
}
// ❌ Wrong - mixing component IDs
.imgly.modifyDockItems { _, items in
items.remove(id: NavigationBar.Buttons.ID.undo) // Wrong component!
}

Container Remains Visible#

Symptom: Component background/container still visible after removing all items

Cause: Expected behavior—only dock supports container hiding

Solution: This is by design. For components other than dock, removing all items leaves an empty container. If container visibility is critical, consider layout adjustments or alternative UI structures.

Error: ID Does Not Exist#

Symptom: Runtime error The 'remove' operation was invoked with id '...' which does not exist

Causes:

  • Button ID doesn’t exist in component’s default configuration
  • Typo in ID string
  • Button already removed earlier

Solutions:

// ✅ Verify button exists in component
// Check Dock.Buttons.ID, NavigationBar.Buttons.ID, etc. enums
// ✅ Use ID constants, not strings
items.remove(id: Dock.Buttons.ID.elementsLibrary) // Correct
// ❌ Don't use string literals
items.remove(id: "elementsLibrary") // Error-prone
// ✅ Don't remove same ID twice
items.remove(id: Dock.Buttons.ID.elementsLibrary)
// items.remove(id: Dock.Buttons.ID.elementsLibrary) // Error!

Next Steps#

Explore related UI customization guides: