Skip to content
Product block

Recent Search List

The empty state of a search box, filled with the searches that are worth repeating and the ones worth saving.

150 linesNo dependenciesAdded 9 Sept 2026Updated 10 Sept 2026
  • search
  • recent
  • history
  • empty state
  • command

What's included

  • components/recent-search-list.tsx
  • No runtime dependencies

Works with

  • React
  • Next.js
  • Tailwind CSS
  • TypeScript

npx hoverlab add recent-search-list

Or over MCP, from your editor's agent — no account needed.

License

Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.

Was this useful?

Start a page with this section — add more, order them, and leave with the page source.

Preview

Pick up where you left off

An empty search box is the most common state of a search box, and it is usually blank. Recent queries are the cheapest useful thing to put there, and the result count is what makes them worth re-running.

Rendered live in your current theme — this is the same component whose source is below, not a screenshot of it.

Source

components/recent-search-list.tsx
'use client'

/**
 * <RecentSearchList> — The empty state of a search box, filled with the searches that are worth repeating and the ones worth saving.
 *
 * The empty state is the most common state of a search box and it is
 * usually blank. The layout problem is what to put there before anything has
 * been typed, and the obvious wrong answer is suggested or trending
 * searches — those are the product talking about itself, and they are
 * identical for every user.
 *
 * Recent queries are the cheapest thing that is actually about this person,
 * and the result count is what makes them worth re-running rather than just
 * a history log.
 *
 * The last row returned nothing and is kept. That is the decision worth
 * defending: an empty result is information — it says this filter
 * combination has no matches, which someone re-running it wants to know
 * before they type it again. Pruning zero-result searches is a tidiness
 * instinct that removes the most useful row.
 *
 * The quoted row exists to document a real behaviour: a phrase in quotes is
 * stored and re-run verbatim rather than re-tokenised, so re-running it
 * gives the same results rather than a fuzzier superset.
 *
 * Rows are buttons with `aria-pressed` since running one is the whole point,
 * and `status` is separate from `tone` so the counts read without colour. In
 * a real command palette this list also needs roving focus and arrow-key
 * navigation; the scaffold's tab-through list is correct for a panel and not
 * for an overlay. The demo selects the first row, the most-run query.
 */

import * as React from 'react'

type Tone = 'neutral' | 'positive' | 'warning' | 'critical'

export interface RecentSearchListRow {
  id: string
  label: string
  detail?: string
  tone?: Tone
  /** What the badge says. Falls back to the tone name when absent. */
  status?: string
}

export interface RecentSearchListProps {
  heading?: string
  intro?: string
  rows?: RecentSearchListRow[]
  className?: string
}

/*
  Tones as complete utility classes, never assembled from fragments.
  Tailwind scans source text, so `text-${tone}-foreground` produces no
  class at all — the same failure as an undefined token, and just as
  invisible in review.
*/
const TONE_CLASS: Record<Tone, string> = {
  neutral: 'bg-muted text-muted-foreground',
  positive: 'bg-primary/10 text-primary',
  warning: 'bg-accent text-accent-foreground',
  critical: 'bg-destructive/10 text-destructive',
}

const ROWS: RecentSearchListRow[] = [
  { id: "row-1", label: "status:open assignee:me", detail: "Run four times this week. The closest thing you have to a saved view.", tone: "positive", status: "12 results" },
  { id: "row-2", label: "invoice overdue", detail: "Run yesterday. Two more have gone overdue since.", tone: "warning", status: "7 results" },
  { id: "row-3", label: "\"cannot log in\"", detail: "Exact phrase. Quoted searches are kept verbatim rather than re-tokenised.", tone: "neutral", status: "3 results" },
  { id: "row-4", label: "region:eu plan:enterprise", detail: "Returned nothing last time. Kept anyway — an empty result is information.", tone: "neutral", status: "0 results" },
]

export function RecentSearchList({
  heading = "Pick up where you left off",
  intro = "An empty search box is the most common state of a search box, and it is usually blank. Recent queries are the cheapest useful thing to put there, and the result count is what makes them worth re-running.",
  rows = ROWS,
  className,
}: RecentSearchListProps) {
  /*
    Per-instance prefix for every id this block emits.

    The literals these replaced were a latent duplicate the moment the
    block appeared twice on one document, and `aria-labelledby` on a
    duplicated id resolves to the first match -- so the second copy was
    labelled by the first copy's heading. Client component, so `useId` is
    the right tool.
  */
  const uid = React.useId()

  const [selected, setSelected] = React.useState<string | null>(rows[0]?.id ?? null)

  return (
    <section
      aria-labelledby={`${uid}-recent-search-list-heading`}
      className={`w-full bg-background px-6 py-16 ${className ?? ''}`}
    >
      <div className="mx-auto max-w-3xl">
        <h2
          id={`${uid}-recent-search-list-heading`}
          className="text-2xl font-semibold tracking-tight text-foreground"
        >
          {heading}
        </h2>
        <p className="mt-2 text-sm text-muted-foreground">{intro}</p>

        <ul className="mt-8 divide-y divide-border overflow-hidden rounded-xl border border-border bg-card">
          {rows.map((row) => {
            const isSelected = row.id === selected
            return (
              <li key={row.id}>
                {/*
                  A button, not a div with onClick. The row is operable, so
                  it has to be reachable by keyboard and announce its
                  selected state — aria-pressed is what carries that.
                */}
                <button
                  type="button"
                  aria-pressed={isSelected}
                  onClick={() => setSelected(row.id)}
                  className={`flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ${
                    isSelected ? 'bg-muted/40' : ''
                  }`}
                >
                  <span className="min-w-0 flex-1">
                    <span className="block truncate text-sm font-medium text-foreground">
                      {row.label}
                    </span>
                    {row.detail ? (
                      <span className="mt-0.5 block text-sm text-muted-foreground">
                        {row.detail}
                      </span>
                    ) : null}
                  </span>
                  <span
                    className={`shrink-0 rounded-full px-2.5 py-1 text-xs font-medium ${
                      TONE_CLASS[row.tone ?? 'neutral']
                    }`}
                  >
                    {row.status ?? row.tone ?? 'neutral'}
                  </span>
                </button>
              </li>
            )
          })}
        </ul>
      </div>
    </section>
  )
}

Before you paste

  • Styling is Tailwind utility classes on semantic tokens (bg-card, text-muted-foreground) — it inherits your theme instead of overriding it.
  • Nothing to install. No component library, no icon package.
  • Every prop has a default, so it renders standalone before you wire it up.

Where it goes

Drop it at components/recent-search-list.tsx and import it where you need the section:

import { RecentSearchList } from '@/components/recent-search-list'

Customize

1 of this block’s props are simple enough to drive from here. Change them and the block below re-renders — it is the same component whose source is above, not a mock of it. Everything else it accepts is in the table underneath.

Props

Read out of the component’s own type and signature, so this cannot drift from the source below. Every prop has a default — the component renders standalone before you pass it anything.

PropTypeDefault
headingstring"Pick up where you left off"
introstring—
rowsRecentSearchListRow[]ROWS
classNamestring—

Not using React?

The same block rendered once to markup, wrapped as a file your framework compiles. Tailwind classes are framework-agnostic, so the design transfers intact — the behaviour does not.

This block is interactive. The markup below is its initial state with the event handlers stripped — you will need to re-wire the behaviour in your framework.

recent-search-list.html
<!--
  Recent Search List — markup from the Hoverlab catalog.

  This is the block rendered once to HTML and wrapped as a component
  file. It is not a port of the React source: the Tailwind classes carry
  the design, which is the part that took the work, and they are the same
  in every framework.

  This block is interactive in React and the handlers are NOT here.
  Buttons, toggles and menus render in their initial state and do
  nothing until you wire them up.
-->
<section aria-labelledby="_R_0_-recent-search-list-heading" class="w-full bg-background px-6 py-16 ">
  <div class="mx-auto max-w-3xl">
    <h2 id="_R_0_-recent-search-list-heading" class="text-2xl font-semibold tracking-tight text-foreground">Pick up where you left off</h2>
    <p class="mt-2 text-sm text-muted-foreground">An empty search box is the most common state of a search box, and it is usually blank. Recent queries are the cheapest useful thing to put there, and the result count is what makes them worth re-running.</p>
    <ul class="mt-8 divide-y divide-border overflow-hidden rounded-xl border border-border bg-card">
      <li>
        <button type="button" aria-pressed="true" class="flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset bg-muted/40">
          <span class="min-w-0 flex-1">
            <span class="block truncate text-sm font-medium text-foreground">status:open assignee:me</span>
            <span class="mt-0.5 block text-sm text-muted-foreground">Run four times this week. The closest thing you have to a saved view.</span>
          </span>
          <span class="shrink-0 rounded-full px-2.5 py-1 text-xs font-medium bg-primary/10 text-primary">12 results</span>
        </button>
      </li>
      <li>
        <button type="button" aria-pressed="false" class="flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ">
          <span class="min-w-0 flex-1">
            <span class="block truncate text-sm font-medium text-foreground">invoice overdue</span>
            <span class="mt-0.5 block text-sm text-muted-foreground">Run yesterday. Two more have gone overdue since.</span>
          </span>
          <span class="shrink-0 rounded-full px-2.5 py-1 text-xs font-medium bg-accent text-accent-foreground">7 results</span>
        </button>
      </li>
      <li>
        <button type="button" aria-pressed="false" class="flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ">
          <span class="min-w-0 flex-1">
            <span class="block truncate text-sm font-medium text-foreground">&quot;cannot log in&quot;</span>
            <span class="mt-0.5 block text-sm text-muted-foreground">Exact phrase. Quoted searches are kept verbatim rather than re-tokenised.</span>
          </span>
          <span class="shrink-0 rounded-full px-2.5 py-1 text-xs font-medium bg-muted text-muted-foreground">3 results</span>
        </button>
      </li>
      <li>
        <button type="button" aria-pressed="false" class="flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ">
          <span class="min-w-0 flex-1">
            <span class="block truncate text-sm font-medium text-foreground">region:eu plan:enterprise</span>
            <span class="mt-0.5 block text-sm text-muted-foreground">Returned nothing last time. Kept anyway — an empty result is information.</span>
          </span>
          <span class="shrink-0 rounded-full px-2.5 py-1 text-xs font-medium bg-muted text-muted-foreground">0 results</span>
        </button>
      </li>
    </ul>
  </div>
</section>
  • This is rendered HTML, not a translation of the React source. The Tailwind classes carry the design and work in any framework.
  • It is one frame: the component in its initial state, with no props applied beyond the defaults.
  • This block is interactive in React — toggles, menus or form state. None of that survives here; the markup is the closed/default state and the handlers are gone. Re-wire them in your own framework.
  • Requires Tailwind, and the design tokens the classes reference (bg-card, text-muted-foreground, and so on). The template ZIPs ship a globals.css that defines them.

What each framework gets across the whole catalog — effects convert properly; this rung is markup.

For AI

The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.

See the prompt

Used in these pages

Want the whole screen instead of this one section? Open a page and copy it entire.

9 more blocks in Command & Search

All of them free to read, copy and install — no account, no locked tiles, no watermarked preview. The whole catalog is open, and so are the API and the CLI.

Browse Command & Search

Shipping one commercially

Copying the code is free. Putting it in client work or a paid product is what Pro is for — the licence, not the access.

  • A commercial licence for everything in the catalog
  • Unlimited bundle exports, in Vue, Svelte and Tailwind
  • One payment — no subscription, nothing to renew
Pro — $79 once

More Command & Search blocks

View category
Open the full page for this block

Command Palette

The ⌘K switcher done properly: focus stays in the input while aria-activedescendant moves, arrows wrap, and the highlight resets on every query change.

Command & Search280 lines1 dep

Grouped Search Results

Results grouped by section with visible breadcrumb paths and <mark>-highlighted matches — users recognise where a result lives faster than they read its snippet.

Command & Search194 lines1 dep
Open the full page for this block

Keyboard Shortcuts Sheet

The "?" overlay, with chords written once in one notation and rendered per platform — mod becomes Command on Apple and Ctrl everywhere else, decided after mount so the markup never mismatches.

Command & Search252 lines1 dep
Open the full page for this block

Applied Filters Bar

The strip above a result set that answers "why am I only seeing four things" — every active constraint as a removable chip, with the excluded count beside it.

Command & Search238 lines1 dep
Open the full page for this block

Header Search with Suggestions

The field in the header, not the palette over it: Enter searches for what you typed unless you arrowed to a suggestion, late responses are dropped by sequence number, and recent searches are removable one at a time.

Command & Search357 lines1 dep
Open the full page for this block

Faceted Refinement Panel

Faceted search with result counts on every option, zero-count options kept visible and disabled so the list stays stable, and a note explaining why the counts do not sum.

Command & Search276 lines1 dep

Search Scope Switcher

One query counted across every scope it could have matched, as a real tablist with arrow-key movement — so an answer that is nowhere is visible without opening four tabs.

Command & Search247 lines1 dep
Open the full page for this block

Faceted Search Results

The whole faceted search assembled - rail, chips, live count and sort - with the intersection actually applied and relevance offered only when there is a query.

Command & Search388 lines1 dep
Open the full page for this block

Range Facet with Histogram

The facet that is a number: a distribution over a dual-thumb slider built from two real range inputs, with typed bounds clamped on blur rather than per keystroke.

Command & Search272 lines1 dep