Search Docs
Loading...
Skip to content

Theming

Match the editor’s color scheme to your app’s design by following the system appearance, forcing a specific scheme, or letting users switch at runtime.

CE.SDK editor displayed in dark mode after adopting the system color scheme

3 mins
estimated time
GitHub

CE.SDK’s editor is a SwiftUI view, so theming uses the standard SwiftUI colorScheme environment. By default the editor inherits its color scheme from the surrounding view hierarchy, which itself defaults to the user’s system appearance. You override the scheme with SwiftUI’s preferredColorScheme(_:) modifier — there is no separate theming API on the editor itself.

Follow the System Appearance#

The default behavior: apply no preferredColorScheme and the editor adopts whichever color scheme is in effect for its parent view. On most apps that means iOS’s light or dark setting.

var editorFollowingSystem: some View {
Editor(settings)
.imgly.configuration { GuideEditorConfiguration() }
}

Force a Specific Color Scheme#

Pin the editor to a particular scheme by attaching .preferredColorScheme(.light) or .preferredColorScheme(.dark) to the Editor view. This is the right choice when your app’s UI is committed to a single appearance.

var editorForcedDark: some View {
Editor(settings)
.imgly.configuration { GuideEditorConfiguration() }
.preferredColorScheme(.dark)
}

Switch Themes at Runtime#

Drive the scheme from @State to let users choose between system, light, and dark while the editor is presented. Passing nil to preferredColorScheme restores inheritance from the parent view — the same behavior as omitting the modifier — so you can offer a “System” option without removing and re-adding the editor.

var editorWithRuntimeToggle: some View {
Editor(settings)
.imgly.configuration { GuideEditorConfiguration() }
.preferredColorScheme(selectedTheme.colorScheme)
}

The ThemeOption enum in the sample maps each user-facing choice to an optional ColorScheme: .system resolves to nil, .light to .light, and .dark to .dark.

API Reference#

APIPurpose
@Environment(\.colorScheme)Reads the resolved color scheme inside any SwiftUI view. Useful when a sheet or custom component needs to react to the active scheme.
.preferredColorScheme(_:)Overrides the color scheme for the modified view and its descendants. Pass .light, .dark, or nil to inherit from the parent view.

Next Steps#

  • Solutions — Browse the prebuilt editor configurations that ship with the SDK.