Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Apple docs
ActionsApple

Language toggle

Cycle to the next locale with a pill that shows that locale.

Public APILumenLanguageToggleApple / 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 Language toggle

Use it for two or three locales. The host applies the locale; use a select for longer lists.

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

struct LanguageSetting: View {
    @State private var language = "en"

    var body: some View {
        LumenLanguageToggle(value: $language, locales: [
            LumenLocaleOption("English", value: "en"),
            LumenLocaleOption("Español", value: "es")
        ])
        .environment(\.locale, Locale(identifier: language))
    }
}
Apple
A pill that shows the next language, tagged with its language identifier, and cycles the app between English and Spanish.

Reference

Public API

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

APIValues or typeDefaultDescription
value / locales / labelTemplatecurrent locale / label and value pairs / accessible name templatefirst locale / English, Español / Change language from {current} to {next}Use it for two or three locales.

Native behavior

Design and accessibility

When to use it

Use it for two or three locales. The host applies the locale; use a select for longer lists.

Accessibility

The label reads the current and the next language.

Shared component

Available on other platforms

React NativeAndroid / Compose Web
Apple docsSwiftUI package