Search bar with find as you type autosuggestion along with a LiveView

I think @paulstatezny was saying to build it with LiveView, but you don’t need to rewrite everything as one big nested parent LiveView.

If I’m not mistaken, you can write your search box as a standalone LiveView and then live_render(conn/socket, SearchBoxLive) from any view or template, even the root template. It will run as its own isolated LiveView on any page without changing anything else. You might need to check out the :sticky option and remove the live layout in your mount callback with {:ok, socket, layout: false}.

Phoenix.LiveView.Helpers.live_render/3

1 Like