Recent Searches
Type for the cancel button; click the magnifier for the recents menu
Search Field
/ NSSearchField · View.searchable(text:placement:prompt:) /
also called search box, search bar, NSSearchField, searchable field
A search field is a text input specialized for filtering or finding content. On macOS it normally includes a magnifying-glass search button, a cancel button that appears for a nonempty query, and optionally a menu of recent searches. SwiftUI's searchable modifier places the platform search field in an appropriate location such as the toolbar.
Anatomy — every part, named
- 1Search button
NSSearchFieldCell.searchButtonCellThe magnifying glass inside the leading edge is the search button, not just a decorative placeholder icon.
- 2Cancel button
NSSearchFieldCell.cancelButtonCell“The little x that clears the search” is the field's cancel button.
- 3Recent-searches menu
NSSearchFieldCell.searchMenuTemplateThe menu attached to the search icon can list recent queries and a Clear Recents command.
Prompt — paste into your agent
Use a native Search Field with NSSearchField (SwiftUI: View.searchable), preserving its leading search button, trailing cancel button when text is present, and optional recent-search menu from NSSearchFieldCell.searchMenuTemplate.
In code
The exact names this thing goes by in code — each row is one framework’s word for it. Use the row that matches your project (or paste it into your prompt).
| AppKit | NSSearchField | |
| SwiftUI | View.searchable(text:placement:prompt:) | |
| AppKit | NSSearchFieldCell |