How to check dark mode with color scheme in SwiftUI

Issue #692

Use colorScheme environment, for now it has 2 cases dark and light

struct MainView: View {
    @Environment(\.colorScheme) var colorScheme

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

I’m open source contributor, writer, speaker and product maker.

Start the conversation