Screen · Productivity

Search SwiftUI Screen

A search screen with recent items and quick actions, and a fuzzy command palette with hold-and-slide to run.

A workspace search screen: recent documents and people as blocks, quick actions, and a native command palette in a sheet with fuzzy search, grouped results plus Recent, one matched-geometry highlight with selection ticks, hold-and-slide to run and drag to dismiss.

  • SwiftUI
  • iOS 17.0+
  • command-palette
Get SwiftPieces Pro

$199 once, every piece included. See how installing works · Sign in

01

What's included

SwiftUI source you own, built on Apple frameworks only.

  • A search home with recents and quick actions
  • Fuzzy search with grouped results and Recent
  • One matched-geometry highlight with selection ticks
  • Hold and slide to run a command; drag to dismiss

In the Build Kit

Native (style), Neon (style), Productivity (brief). Your agent builds around this screen in the same design.

Used in

Travel App (template)

02

Implementation notes

How it behaves, what it handles, and the decisions behind it.

A workspace search screen: a two-tone title, a search pill, recent documents as blocks, people and quick actions, with CommandPalette in a sheet. The palette opens at the medium detent with the search field focused. Typing filters instantly through a private fuzzy scorer; with an empty query the list shows a Recent section followed by every group in order. One highlight moves between rows with matchedGeometryEffect and ticks on every change. Hold on the list, then slide: the highlight follows the finger without lifting it, and releasing runs the highlighted command. Tap a row or press Go on the keyboard to run it too, and pull the grabber down to dismiss.

Notes

  • PaletteCommand carries title, symbol, group, keywords and a @MainActor @Sendable action, so a command list can be built anywhere.
  • The scorer is a subsequence match: every query character must appear in order in the title or in a keyword. Prefix, word-start and adjacent hits score higher, longer targets score slightly lower, and keyword hits are weighted below title hits. Empty results show ContentUnavailableView.search.
  • Scrub is a LongPressGesture(0.25s) sequenced before a DragGesture; while it runs the scroll view is disabled so the list holds still. Row frames are measured with onGeometryChange in the list's named coordinate space.
  • Running a command inserts its id at the front of recents (capped at eight), dismisses, then calls the action.
  • Rows are VoiceOver buttons with .isSelected on the highlight; group titles carry .isHeader. Reduce Motion shortens the highlight move to a short ease-out.
  • On the screen, the pill and the Search tab both open the palette, and every command writes back: opening a document moves its block to the front of the rail, New doc files one, and a toast takes the tab bar's place to confirm.
  • CommandPaletteExample at the end of CommandPalette.swift is the Search screen from the preview.