<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/EnvironmentValues/colorScheme",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17EnvironmentValuesV11colorSchemeAA05ColorF0Ovp"
  },
  "title" : "colorScheme"
}
-->

# colorScheme

The color scheme of this environment.

```
var colorScheme: ColorScheme { get set }
```

## Discussion

Read this environment value from within a view to find out if SwiftUI
is currently displaying the view using the [`ColorScheme.light`](/documentation/SwiftUI/ColorScheme/light) or
[`ColorScheme.dark`](/documentation/SwiftUI/ColorScheme/dark) appearance. The value that you receive depends on
whether the user has enabled Dark Mode, possibly superseded by
the configuration of the current presentation’s view hierarchy.

```
@Environment(\.colorScheme) private var colorScheme

var body: some View {
    Text(colorScheme == .dark ? "Dark" : "Light")
}
```

You can set the `colorScheme` environment value directly,
but that usually isn’t what you want. Doing so changes the color
scheme of the given view and its child views but *not* the views
above it in the view hierarchy. Instead, set a color scheme using the
[`preferredColorScheme(_:)`](/documentation/SwiftUI/View/preferredColorScheme(_:)) modifier, which also propagates the
value up through the view hierarchy to the enclosing presentation, like
a sheet or a window.

When adjusting your app’s user interface to match the color scheme,
consider also checking the [`colorSchemeContrast`](/documentation/SwiftUI/EnvironmentValues/colorSchemeContrast)
property, which reflects a system-wide contrast setting that the user
controls. For information, see
<doc://com.apple.documentation/design/Human-Interface-Guidelines/accessibility>
in the Human Interface Guidelines.

> Note: If you only need to provide different colors or
> images for different color scheme and contrast settings, do that in
> your app’s Asset Catalog. See
> <doc://com.apple.documentation/documentation/Xcode/asset-management>.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)