Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Apple docs
ActionsApple

Theme toggle

Switch between the light and dark scheme with one round button.

Public APILumenThemeToggleApple / SwiftUISwift product: LumenUI

Apple availability

Supported native targets

Import LumenUI in the target that uses this component. iPad support follows the iOS package baseline and uses native iPad layout behavior.

iPhone · iOS 16+iPad · iPadOS 16+Mac · macOS 13+Apple TV · tvOS 16+Apple Vision · visionOS 1+Apple Watch · watchOS 9+

Native example

Use Theme toggle

The host owns the scheme and applies it. Use a segmented control when people also need a system option.

Theme toggle rendered in the iPhone simulator Lumen playground
Captured exampleiPhone simulatorView dark appearance
swift
import LumenUI
import SwiftUI

struct AppearanceSetting: View {
    @State private var scheme: LumenColorScheme = .light

    var body: some View {
        HStack(spacing: LumenSpacing.md) {
            LumenThemeToggle(scheme: $scheme)
            LumenText("Change the site theme", tone: .soft)
        }
        .lumenTheme(scheme == .dark ? .dark : .light)
    }
}
Apple
A round sun and moon button that switches the app between the light and dark Lumen themes.

Reference

Public API

The primary shared and platform-specific options exposed by LumenThemeToggle.

APIValues or typeDefaultDescription
scheme / onSchemeChange / labelcurrent scheme / change callback / accessible namerequired / required / Toggle color themeThe host owns the scheme and applies it.

Native behavior

Design and accessibility

When to use it

The host owns the scheme and applies it. Use a segmented control when people also need a system option.

Accessibility

Named Toggle color theme; the dark scheme reads as pressed.

Shared component

Available on other platforms

React NativeAndroid / Compose Web
Apple docsSwiftUI package