typeSelectEquivalent
Sets an explicit type select equivalent text in a collection, such as a list or table.
Overloads
2 ways to call compose().typeSelectEquivalent(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().typeSelectEquivalent(stringResource: string)@export(implementation) nonisolated func typeSelectEquivalent(
_ stringResource: LocalizedStringResource
) -> some View2 more Swift overloads share this form
@export(implementation) nonisolated func typeSelectEquivalent(
_ stringKey: LocalizedStringKey
) -> some View@export(implementation) nonisolated func typeSelectEquivalent<S>(
_ string: S
) -> some View
where S : StringProtocolParameters
stringResource*stringThe localized string resource to use as a
Discussion
By default, a type select equivalent is automatically derived from any
Text or TextField content in a list or table. In the below example,
type select can be used to select a person, even though no explicit
value has been set.
List(people, selection: $selectedPersonID) { person in
Label {
Text(person.name)
} icon: {
person.avatar
}
}An explicit type select value should be set when there is no textual content or when a different value is desired compared to what's displayed in the view. Explicit values also provide a more performant for complex view types. In the below example, type select is explicitly set to allow selection of views that otherwise only display an image.
List(people, selection: $selectedPersonID) { person in
person.avatar
.accessibilityLabel(person.name)
.typeSelectEquivalent(person.name)
}Setting an empty string value disables text selection for the view,
and a value of nil results in the view using its default value.
type select equivalent for a view in a collection.
See also
More in Other modifiers.
- contentMarginsConfigures the content margin for a provided placement.
- idBinds a view's identity to the given proxy value.
- modifierApplies a modifier to a view and returns a new view.
- persistentSystemOverlaysSets the preferred visibility of the non-transient system views overlaying the app.
- renameActionSets the rename action in the environment to update focus state.
- tagSets the unique tag value of this view.