LAST CHANCE: Save 50% on all my Swift books and bundles! >>

SOLVED: .searchable behavior change? Day 96

Forums > 100 Days of SwiftUI

Hi all,

In Day 96, Paul implements a .searchable search bar that shows ideal behavior (imo) - the search bar stays hidden until the user pulls down slightly on the view, causing the search bar to appear to slide out from under the navigation bar into view.

I noticed that this behavior does not seem to still be present in the current version of Swift - when using .searchable, the search bar is always visible. A forum post from about a year ago seems to note this as well, but I'm having trouble confirming this elsewhere. Am I crazy, does this behavior still exist?

Paul's code, in case you'd like to test it yourself:

struct ContentView: View {
    @State private var searchText = ""
    let allNames = ["Subh", "Vina", "Melvin", "Stefanie"]

    var body: some View {
        NavigationView {
            List(filteredNames, id: \.self) { name in
            .searchable(text: $searchText, prompt: "Look for something")

    var filteredNames: [String] {
        if searchText.isEmpty {
            return allNames
        } else {
            return allNames.filter { $0.contains(searchText) }



Quick answer Yes. Think they have changed it to make the search more accessible (do not quote me on that). However you can change it to alway show with by add placement to .always this will not hid it when scrolling.



Hey Nigel! Thanks as always for taking a look :) I'm actually looking for the opposite behavior - I want the search bar to be hidden until you pull down (see 3:20 in Paul's video linked above). It's a minor visual annoyance if anything, but I was curious if I'm doing something wrong or if the searchable visibility really has changed.


Yes, search bar has changed

There are a number of options for placement depending on platform. Check out the Document in link above.

However in iOS it mainly down to two.

  1. .automatic (This is default) - This will show the search bar then hid it when scrolling. This will also change depending on platform and size class.
  2. .always - This will show search bar always even when scrolling.

My guess is that Apple may of thought that the search bar was to hidden and user did not know about it, and therefore make more available 🤷‍


I thought I was going nuts with this problem! Glad to see others have run into it, too.

My app's main UI is a TabView, and oddly the searchbar is still hidden by default on the first tabview tab displayed, but not the others. And it's not hidden on the first tabview tab consistently. Not happy with the change...I wonder whether this is a bug in the searchable code.


Hacking with Swift is sponsored by Essential Developer.

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until July 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.