Skip to main content
.colorScheme(scheme: "light" | "dark")
scheme
"light" | "dark"
required
The color scheme to apply to this component subtree.

Support

Usage

Force dark mode on a section

VStack([
    Text("Dark Section"),
    Text("Always dark")
])
    .padding(16)
    .colorScheme("dark")

Force light mode on a card

VStack([
    Text("Light Card"),
    Text("Always light appearance")
])
    .padding(16)
    .background(Color("white"))
    .colorScheme("light")

Notes

This modifier overrides the system color scheme for the component and all of its descendants. It does not affect siblings or ancestors. Use the environment modifier with the "colorScheme" key for the same effect.

See Also