ThemeProvider
@MainActor
public struct ThemeProvider<Content> : View where Content : View
A SwiftUI view that injects a visual theme (Theme) into the environment based on the system color scheme.
Use ThemeProvider to wrap your app or specific view hierarchies and enable access to the current theme
via @Environment(\.appTheme). It automatically switches between light and dark theme variants.
-
The theme used when the system is in light mode.
Declaration
Swift
@MainActor public let lightTheme: Theme -
The theme used when the system is in dark mode.
Declaration
Swift
@MainActor public let darkTheme: Theme -
The content view to wrap in the themed environment.
Declaration
Swift
@MainActor public let content: () -> Content -
Initializes a
ThemeProviderwith optional light and dark themes.Declaration
Parameters
lightThe theme to apply in light mode. Defaults to
.defaultLight.darkThe theme to apply in dark mode. Defaults to
.defaultDark.contentThe root view that will inherit the themed environment.
-
The view body that injects the current theme into the environment based on the active color scheme.
Declaration
Swift
@MainActor public var body: some View { get }