Skip to main content
196

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Apple docs
FormsApple

Autocomplete

Select from application-provided search results with loading, empty, and retry feedback.

Public APILumenAutocompleteApple / 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 Vision · visionOS 1+

Native example

Use Autocomplete

The application supplies filtered results with unique non-null values, owns request cancellation, and clears stale selection after query edits. React Native and Compose selection emit the option label before the selected value; SwiftUI updates bindings directly.

Autocomplete rendered in the iPhone simulator Lumen playground
Captured exampleiPhone simulator
swift
import LumenUI
import SwiftUI

struct ProjectSearch: View {
    @State private var query = ""
    @State private var selected: String? = nil
    private let projects = [LumenAutocompleteOption(value: "lumen", label: "Lumen"),
                            LumenAutocompleteOption(value: "studio", label: "Studio")]
    var body: some View {
        LumenAutocomplete("Project", query: $query, selection: $selected,
            options: projects.filter { query.isEmpty || $0.label.localizedCaseInsensitiveContains(query) },
            emptyLabel: "No projects", dismissLabel: "Close results")
    }
}

Reference

Public API

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

APIValues or typeDefaultDescription
_ labelStringRequiredNames the editable search field.
query / selectionBinding<String> / Binding<Value?>RequiredControls query and selected identity; the component clears selection on query edits.
options[LumenAutocompleteOption<Value>]RequiredUnique Hashable values with label, description and disabled state.
loading / resultsErrorMessage / onRetryBool / String? / (() -> Void)?false / nil / nilHides stale results and offers application-owned recovery.
loadingLabel / emptyLabel / retryLabel / dismissLabelStringLoading results / No results / Retry / Close resultsLocalizes status and result dismissal.
description / errorMessageString?nilProvides localized supporting copy or host validation.
readOnly / .disabled(...)BoolfalseBlocks editing; disabled state comes from the SwiftUI environment.

Native behavior

Design and accessibility

When to use it

The application supplies filtered results with unique non-null values, owns request cancellation, and clears stale selection after query edits. React Native and Compose selection emit the option label before the selected value; SwiftUI updates bindings directly.

Accessibility

Preserves native editable dropdown focus, selected and disabled option semantics, and announced loading, empty, and recovery states.

Shared component

Available on other platforms

React NativeAndroid / Compose
Apple docsSwiftUI package