<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSSearchField",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSSearchField"
  },
  "title" : "NSSearchField"
}
-->

# NSSearchField

A text field optimized for performing text-based searches.

```
class NSSearchField
```

## Overview

[`NSSearchField`](/documentation/AppKit/NSSearchField) provides a customized text field for entering search data. The class also provides a search button, a cancel button, and a pop-up icon menu for listing recent search strings and custom search categories.

An [`NSSearchField`](/documentation/AppKit/NSSearchField) object wraps an [`NSSearchFieldCell`](/documentation/AppKit/NSSearchFieldCell) object. The cell provides access to most search field attributes and a comprehensive programmatic interface for manipulating the search field. You can use an [`NSSearchField`](/documentation/AppKit/NSSearchField) object to manipulate some aspects of the search field.

For additional information about search fields and how to implement them, see the [`NSSearchFieldCell`](/documentation/AppKit/NSSearchFieldCell) class.

## Topics

### Managing Search

[`delegate`](/documentation/AppKit/NSSearchField/delegate)

The delegate for the search field, or `nil` if the search field doesn’t have a delegate.

[`NSSearchFieldDelegate`](/documentation/AppKit/NSSearchFieldDelegate)

A protocol that a search field delegate can use to determine when a search started or ended.

### Managing Menu Templates

[`searchMenuTemplate`](/documentation/AppKit/NSSearchField/searchMenuTemplate)

The menu object used to dynamically construct the search field’s pop-up icon menu.

[`NSSearchFieldClearRecentsMenuItemTag`](/documentation/AppKit/NSSearchField/clearRecentsMenuItemTag)

The menu item for clearing the current set of recent string searches in the menu.

[`NSSearchFieldNoRecentsMenuItemTag`](/documentation/AppKit/NSSearchField/noRecentsMenuItemTag)

The menu item that describes a lack of recent search strings.

[`NSSearchFieldRecentsMenuItemTag`](/documentation/AppKit/NSSearchField/recentsMenuItemTag)

The location of recent search strings in the “recents” menu group.

[`NSSearchFieldRecentsTitleMenuItemTag`](/documentation/AppKit/NSSearchField/recentsTitleMenuItemTag)

The menu item that provides the title of the menu group for recent search strings.

### Managing Search Modes

[`sendsSearchStringImmediately`](/documentation/AppKit/NSSearchField/sendsSearchStringImmediately)

A Boolean value indicating whether the cell calls its action method immediately when an appropriate action occurs.

[`sendsWholeSearchString`](/documentation/AppKit/NSSearchField/sendsWholeSearchString)

A Boolean value indicating whether the cell calls its search action method when the user clicks the search button or presses Return, or after each keystroke.

### Managing Recent Searches

[`recentSearches`](/documentation/AppKit/NSSearchField/recentSearches)

The list of recent search strings for the control.

[`maximumRecents`](/documentation/AppKit/NSSearchField/maximumRecents)

The maximum number of search strings that can appear in the search menu.

[`recentsAutosaveName`](/documentation/AppKit/NSSearchField/recentsAutosaveName-swift.property)

The name under which the search field automatically archives the list of recent search strings.

[`RecentsAutosaveName`](/documentation/AppKit/NSSearchField/RecentsAutosaveName-swift.typealias)

The string that stores the name under which a search field automatically archives a list of recent search strings.

### Getting Search Field Metrics

[`cancelButtonBounds`](/documentation/AppKit/NSSearchField/cancelButtonBounds)

The rectangle for the cancel button within the bounds of the search field.

[`searchButtonBounds`](/documentation/AppKit/NSSearchField/searchButtonBounds)

The rectangle for the search button within the bounds of the search field.

[`searchTextBounds`](/documentation/AppKit/NSSearchField/searchTextBounds)

The rectangle for the search text within the bounds of the search field.

### Deprecated Symbols

[`centersPlaceholder`](/documentation/AppKit/NSSearchField/centersPlaceholder)

A Boolean value that determines whether the search field’s components are centered within the control.

[`-  rectForCancelButtonWhenCentered:`](/documentation/AppKit/NSSearchField/rectForCancelButton(whenCentered:))

The rectangle for the cancel button within the bounds of the search field.

[`-  rectForSearchButtonWhenCentered:`](/documentation/AppKit/NSSearchField/rectForSearchButton(whenCentered:))

The rectangle for the search button within the bounds of the search field.

[`-  rectForSearchTextWhenCentered:`](/documentation/AppKit/NSSearchField/rectForSearchText(whenCentered:))

The rectangle for the search text within the bounds of the field.

## Relationships

### Conforms To

[`NSTouchBarProvider`](/documentation/AppKit/NSTouchBarProvider)

[`NSAppearanceCustomization`](/documentation/AppKit/NSAppearanceCustomization)

[`NSAccessibilityStaticText`](/documentation/AppKit/NSAccessibilityStaticText)

[`NSTextContent`](/documentation/AppKit/NSTextContent)

[`NSAccessibilityElementProtocol`](/documentation/AppKit/NSAccessibilityElementProtocol)

[`NSAccessibilityProtocol`](/documentation/AppKit/NSAccessibilityProtocol)

[`NSAnimatablePropertyContainer`](/documentation/AppKit/NSAnimatablePropertyContainer)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSDraggingDestination`](/documentation/AppKit/NSDraggingDestination)

[`NSUserActivityRestoring`](/documentation/AppKit/NSUserActivityRestoring)

[`NSUserInterfaceValidations`](/documentation/AppKit/NSUserInterfaceValidations)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`NSUserInterfaceItemIdentification`](/documentation/AppKit/NSUserInterfaceItemIdentification)

[`Sendable`](/documentation/Swift/Sendable)

[`NSStandardKeyBindingResponding`](/documentation/AppKit/NSStandardKeyBindingResponding)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSAccessibilityNavigableStaticText`](/documentation/AppKit/NSAccessibilityNavigableStaticText)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Inherits From

[`NSTextField`](/documentation/AppKit/NSTextField)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)