Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Android docs
ActionsAndroid

Theme toggle

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

Public APILumenThemeToggleAndroid / Compose

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 Android phone emulator Lumen playground
Captured exampleAndroid phone emulatorView dark appearance
kotlin
@Composable
fun App() {
    val systemDark = isSystemInDarkTheme()
    var darkTheme by rememberSaveable { mutableStateOf(systemDark) }
    LumenTheme(darkTheme = darkTheme) {
        Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(LumenSpacing.Md)) {
            LumenText("Appearance", variant = LumenTextVariant.Label)
            LumenThemeToggle(darkTheme = darkTheme, onDarkThemeChange = { darkTheme = it })
        }
    }
}
Android
A round sun and moon button that switches the app between its 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 NativeApple / SwiftUI Web
Android docsCompose module