ColorScheme
The possible color schemes, corresponding to the light and dark appearances.
Declaration
type ColorScheme = 'dark' | 'light';enum ColorSchemePass a literal, or build one with SwiftUI.ColorScheme from import { SwiftUI } from 'swiftui-react-native'.
Type properties
'dark'SwiftUI.ColorScheme.darkThe color scheme that corresponds to a dark appearance.
'light'SwiftUI.ColorScheme.lightThe color scheme that corresponds to a light appearance.
Overview
You receive a color scheme value when you read the
EnvironmentValues.colorScheme environment value. The value tells you if
a light or dark appearance currently applies to the view. SwiftUI updates
the value whenever the appearance changes, and redraws views that
depend on the value. For example, the following Text view automatically
updates when the user enables Dark Mode:
@Environment(\.colorScheme) private var colorScheme
var body: some View {
Text(colorScheme == .dark ? "Dark" : "Light")
}Set a preferred appearance for a particular view hierarchy to override
the user's Dark Mode setting using the View.preferredColorScheme(_:)
view modifier.
From Apple’s SwiftUI documentation. Code samples there are Swift.
Used by
See also
More in Appearance.
- BackgroundProminenceThe prominence of backgrounds underneath other views.
- BadgeProminenceThe visual prominence of a badge.
- ButtonSizingThe sizing behavior of Buttons and other button-like controls.
- ColorA representation of a color that adapts to a given context.
- ColorRenderingModeThe set of possible working color spaces for color-compositing operations.
- ColorResolvedA concrete color value.
- ColorResolvedHDRA concrete color value, including HDR headroom information.
- ColorRGBColorSpaceA profile that specifies how to interpret a color value for display.
- GlassA structure that defines the configuration of a physical glass material.
- GlassChainGlass with chained calls: SwiftUI.Glass.interactive(...).
- ImageScaleA scale to apply to vector images relative to text.
- ProminenceA type indicating the prominence of a view hierarchy.