When to use it
The host owns the scheme and applies it. Use a segmented control when people also need a system option.
Switch between the light and dark scheme with one round button.
Native example
The host owns the scheme and applies it. Use a segmented control when people also need a system option.
@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 })
}
}
}Reference
The primary shared and platform-specific options exposed by LumenThemeToggle.
| API | Values or type | Default | Description |
|---|---|---|---|
| scheme / onSchemeChange / label | current scheme / change callback / accessible name | required / required / Toggle color theme | The host owns the scheme and applies it. |
Native behavior
The host owns the scheme and applies it. Use a segmented control when people also need a system option.
Named Toggle color theme; the dark scheme reads as pressed.
Shared component