Search on the server (MoviePlz)
A library with filters and a search box that asks the server as you type, and swaps in only the results, from MoviePlz.
2 steps · ends in a library you filter and search on the server
A library can be too big to send to the phone, so the server searches it. In MoviePlz the search box asks the server a moment after you stop typing, and only the list of results is replaced, so the box keeps its focus and the keyboard stays up. The titles here are invented.
Step 1 of 2
The library as the server sends it
Three filter buttons with their counts, a search field in a <form>, and the results: one card per title, in a column with an id, library-results.
<app> <config primary_color="red"/> <screen> <app-bar title="Library"/> <main id="main"> <column style="w-full p-16 gap-12"> <row style="gap-8"> <button variant="filled" size="sm">All (128)</button> <button variant="outlined" size="sm">Films (90)</button> <button variant="outlined" size="sm">Series (38)</button> </row> <form> <input name="q" variant="plain" icon="search" enterkeyhint="search" placeholder="Search titles…" style="h-48 rounded-full bg-red-50 dark:bg-red-950"/> </form> <column id="library-results" style="w-full gap-8"> <column style="w-full rounded-xl bg-red-50 dark:bg-red-950"> <flex column_widths="60px 1"> <column style="h-90 w-60 items-center justify-center rounded-l-xl bg-red-200 dark:bg-red-900"> <icon name="movie size-24 red"/> </column> <column style="px-12 py-10 gap-2"> <text style="font-bold">The Lighthouse Keeper</text> <text style="muted font-sm">Film · 2021</text> </column> </flex> </column> <column style="w-full rounded-xl bg-red-50 dark:bg-red-950"> <flex column_widths="60px 1"> <column style="h-90 w-60 items-center justify-center rounded-l-xl bg-red-200 dark:bg-red-900"> <icon name="tv size-24 red"/> </column> <column style="px-12 py-10 gap-2"> <text style="font-bold">Harbor Lights</text> <text style="muted font-sm">Series · 2019</text> </column> </flex> </column> <column style="w-full rounded-xl bg-red-50 dark:bg-red-950"> <flex column_widths="60px 1"> <column style="h-90 w-60 items-center justify-center rounded-l-xl bg-red-200 dark:bg-red-900"> <icon name="movie size-24 red"/> </column> <column style="px-12 py-10 gap-2"> <text style="font-bold">Night Market</text> <text style="muted font-sm">Film · 2018</text> </column> </flex> </column> <column style="w-full rounded-xl bg-red-50 dark:bg-red-950"> <flex column_widths="60px 1"> <column style="h-90 w-60 items-center justify-center rounded-l-xl bg-red-200 dark:bg-red-900"> <icon name="tv size-24 red"/> </column> <column style="px-12 py-10 gap-2"> <text style="font-bold">Small Hours</text> <text style="muted font-sm">Series · 2022</text> </column> </flex> </column> </column> </column> </main> </screen></app>
Step 2 of 2
Ask the server as you type
The search field gets the same attributes a button does:
action="/library/search.ham"withmethod="GET"sends what's typed asq, because the field is inside a<form>.trigger="change:delay-300ms"sends it 300 milliseconds after the last keystroke, rather than on every one.target="#library-results"andswap="inner"replace only what's inside the results column, never the field itself.
The filters swap the whole screen (target="#main"), so the selected filter and the field's placeholder follow, and each result opens its title's page with navigate:.
MoviePlz's own markup: the library and its results.
<app> <config primary_color="red"/> <screen> <app-bar title="Library"/> <main id="main"> <column style="w-full p-16 gap-12"> <row style="gap-8"> <button action="/library.ham" target="#main" swap="inner" variant="filled" size="sm">All (128)</button> <button action="/library.ham?type=film" target="#main" swap="inner" variant="outlined" size="sm">Films (90)</button> <button action="/library.ham?type=series" target="#main" swap="inner" variant="outlined" size="sm">Series (38)</button> </row> <form> <input name="q" variant="plain" icon="search" enterkeyhint="search" placeholder="Search titles…" action="/library/search.ham" method="GET" target="#library-results" swap="inner" trigger="change:delay-300ms" style="h-48 rounded-full bg-red-50 dark:bg-red-950"/> </form> <column id="library-results" style="w-full gap-8"> <column action="navigate:/library/1.ham" style="w-full rounded-xl bg-red-50 dark:bg-red-950"> <flex column_widths="60px 1"> <column style="h-90 w-60 items-center justify-center rounded-l-xl bg-red-200 dark:bg-red-900"> <icon name="movie size-24 red"/> </column> <column style="px-12 py-10 gap-2"> <text style="font-bold">The Lighthouse Keeper</text> <text style="muted font-sm">Film · 2021</text> </column> </flex> </column> <column action="navigate:/library/2.ham" style="w-full rounded-xl bg-red-50 dark:bg-red-950"> <flex column_widths="60px 1"> <column style="h-90 w-60 items-center justify-center rounded-l-xl bg-red-200 dark:bg-red-900"> <icon name="tv size-24 red"/> </column> <column style="px-12 py-10 gap-2"> <text style="font-bold">Harbor Lights</text> <text style="muted font-sm">Series · 2019</text> </column> </flex> </column> <column action="navigate:/library/3.ham" style="w-full rounded-xl bg-red-50 dark:bg-red-950"> <flex column_widths="60px 1"> <column style="h-90 w-60 items-center justify-center rounded-l-xl bg-red-200 dark:bg-red-900"> <icon name="movie size-24 red"/> </column> <column style="px-12 py-10 gap-2"> <text style="font-bold">Night Market</text> <text style="muted font-sm">Film · 2018</text> </column> </flex> </column> <column action="navigate:/library/4.ham" style="w-full rounded-xl bg-red-50 dark:bg-red-950"> <flex column_widths="60px 1"> <column style="h-90 w-60 items-center justify-center rounded-l-xl bg-red-200 dark:bg-red-900"> <icon name="tv size-24 red"/> </column> <column style="px-12 py-10 gap-2"> <text style="font-bold">Small Hours</text> <text style="muted font-sm">Series · 2022</text> </column> </flex> </column> </column> </column> </main> </screen></app>