Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Apple docs
FormsApple

Secret value

Show a masked value, such as an API key, with show, hide, and copy actions.

Public APILumenSecretValueApple / 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 Secret value

Load secrets on demand with loadValue and hide them after a delay. The mask never shows the value length.

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

struct ApiKeyField: View {
    let loadKey: @MainActor () async throws -> String
    @State private var loadFailed = false

    var body: some View {
        LumenSecretValue("Sandbox API key", loadValue: loadKey, autoHideAfter: 30,
                         onLoadError: { _ in loadFailed = true })
    }
}
Apple
A sandbox API key that loads on reveal, hides itself after 30 seconds and copies to a concealed pasteboard item.

Reference

Public API

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

APIValues or typeDefaultDescription
label / value or loadValue / autoHideAfterfield name / secret or loader / auto-hide delayrequired / required / neverLoad secrets on demand with loadValue and hide them after a delay.

Native behavior

Design and accessibility

When to use it

Load secrets on demand with loadValue and hide them after a delay. The mask never shows the value length.

Accessibility

The toggle exposes expanded state, and loading, hiding, and copy results are announced.

Shared component

Available on other platforms

React NativeAndroid / Compose Web
Apple docsSwiftUI package