---
title: UISearchTextField
framework: uikit
role: symbol
role_heading: Class
path: uikit/uisearchtextfield
---

# UISearchTextField

A view for displaying and editing text and search tokens.

## Declaration

```swift
@MainActor class UISearchTextField
```

## Overview

Overview Use a search text field to display search criteria represented as text and tokens, and allow the user to edit that criteria. Tokens are discrete representations of nontextual content that your app can create and use to represent filters that limit the search results. Tokens always occur contiguously before any text in the search field. UISearchBar hosts a search text field, but you may also use a search text field in other roles, such as the title view of a UINavigationItem. note: The search field assigns text positions (UITextPosition) to tokens as well as text so that users can interact with tokens using selection gestures and keyboard input. If the current selection includes any tokens, selectedTextRange includes their positions. Use the search field’s textualRange property to access the range of just the text without the tokens. Tokens can be programmatically selected by including their position in a range assigned to the selectedTextRange property.

## Topics

### Converting text into tokens

- [replaceTextualPortion(of:with:at:)](uikit/uisearchtextfield/replacetextualportion(of:with:at:).md)
- [textualRange](uikit/uisearchtextfield/textualrange.md)

### Supporting token interactions

- [allowsDeletingTokens](uikit/uisearchtextfield/allowsdeletingtokens.md)
- [allowsCopyingTokens](uikit/uisearchtextfield/allowscopyingtokens.md)
- [delegate](uikit/uitextfield/delegate.md)
- [UISearchTextFieldDelegate](uikit/uisearchtextfielddelegate.md)
- [UISearchTextFieldPasteItem](uikit/uisearchtextfieldpasteitem.md)

### Adding and removing tokens

- [tokens](uikit/uisearchtextfield/tokens.md)
- [insertToken(_:at:)](uikit/uisearchtextfield/inserttoken(_:at:).md)
- [removeToken(at:)](uikit/uisearchtextfield/removetoken(at:).md)

### Customizing token behavior

- [tokenBackgroundColor](uikit/uisearchtextfield/tokenbackgroundcolor.md)
- [tokens(in:)](uikit/uisearchtextfield/tokens(in:).md)
- [positionOfToken(at:)](uikit/uisearchtextfield/positionoftoken(at:).md)

### Providing search suggestions

- [searchSuggestions](uikit/uisearchtextfield/searchsuggestions.md)

## Relationships

### Inherits From

- [UITextField](uikit/uitextfield.md)

### Conforms To

- [CALayerDelegate](quartzcore/calayerdelegate.md)
- [CLBodyIdentifiable](corelocation/clbodyidentifiable.md)
- [CMBodyIdentifiable](coremotion/cmbodyidentifiable.md)
- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSTouchBarProvider](appkit/nstouchbarprovider.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [UIAccessibilityIdentification](uikit/uiaccessibilityidentification.md)
- [UIActivityItemsConfigurationProviding](uikit/uiactivityitemsconfigurationproviding.md)
- [UIAppearance](uikit/uiappearance.md)
- [UIAppearanceContainer](uikit/uiappearancecontainer.md)
- [UIContentSizeCategoryAdjusting](uikit/uicontentsizecategoryadjusting.md)
- [UIContextMenuInteractionDelegate](uikit/uicontextmenuinteractiondelegate.md)
- [UICoordinateSpace](uikit/uicoordinatespace.md)
- [UIDynamicItem](uikit/uidynamicitem.md)
- [UIFocusEnvironment](uikit/uifocusenvironment.md)
- [UIFocusItem](uikit/uifocusitem.md)
- [UIFocusItemContainer](uikit/uifocusitemcontainer.md)
- [UIKeyInput](uikit/uikeyinput.md)
- [UILargeContentViewerItem](uikit/uilargecontentvieweritem.md)
- [UILetterformAwareAdjusting](uikit/uiletterformawareadjusting.md)
- [UIPasteConfigurationSupporting](uikit/uipasteconfigurationsupporting.md)
- [UIPopoverPresentationControllerSourceItem](uikit/uipopoverpresentationcontrollersourceitem.md)
- [UIResponderStandardEditActions](uikit/uiresponderstandardeditactions.md)
- [UITextDraggable](uikit/uitextdraggable.md)
- [UITextDroppable](uikit/uitextdroppable.md)
- [UITextInput](uikit/uitextinput.md)
- [UITextInputTraits](uikit/uitextinputtraits.md)
- [UITextPasteConfigurationSupporting](uikit/uitextpasteconfigurationsupporting.md)
- [UITraitChangeObservable](uikit/uitraitchangeobservable-67e94.md)
- [UITraitEnvironment](uikit/uitraitenvironment.md)
- [UIUserActivityRestoring](uikit/uiuseractivityrestoring.md)

## See Also

### Search field

- [UISearchToken](uikit/uisearchtoken.md)
- [UISearchTextFieldDelegate](uikit/uisearchtextfielddelegate.md)
