TextInputDictationBehavior

A behavior that determines whether a search field offers dictation, and what starts it.

StructureiOS 17.0+visionOS 1.0+TextInputDictationBehavior in SwiftUI

Declaration

React
type TextInputDictationBehavior = 'automatic' | { inline: { activation: TextInputDictationActivation; }; };
Swift
struct TextInputDictationBehavior

Pass a literal, or build one with SwiftUI.TextInputDictationBehavior from import { SwiftUI } from 'swiftui-react-native'.

Type properties

Type methods

Overview

Pass a value of this type to the View.searchDictationBehavior(_:) modifier. Search fields use TextInputDictationBehavior.automatic unless you choose otherwise.

The following example keeps the dictation microphone in the search field, but waits for someone to select it before listening:

NavigationStack {
    RecipeList(matching: query)
}
.searchable(text: $query)
.searchDictationBehavior(.inline(activation: .onSelect))

On visionOS you can remove the microphone from the field entirely with TextInputDictationBehavior.preventDictation.

From Apple’s SwiftUI documentation. Code samples there are Swift.

Used by

See also

More in Text and symbols.