Skip to content
Klarhimmel UI

Search results

App, search results previewApp, search results preview

Install

npx shadcn add @klarhimmel/app-search-results
DetailsAbout, usage, props and more

A results page: a search box, checkbox facets whose counts follow the other filters, active filters as removable chips, a result count that is announced when it…

States

search results in 4 forms: filled, empty, loading, error.

  • state: filled

    Name the section

    Name what is searched

    Say which kinds of things this search covers.

    Filters

    Type
    Price

    5 results for “Name”

    1. Name the first result

      Say in one sentence what this result is and what it includes.

      Type of result · $00

      • First type
      • Second price band
    2. Name the second result

      Say in one sentence what this result is and where it happens.

      Type of result · $00

      • First type
      • First price band
    3. Name the third result

      Say in one sentence what this result is and what comes with it.

      Type of result · $00

      • Second type
      • Second price band
    4. Name the fourth result

      Say in one sentence who this result is for and what it covers.

      Type of result · $00

      • Third type
      • Second price band
    5. Name the fifth result

      Say in one sentence what this result is and how it arrives.

      Type of result · $00

      • First type
      • First price band
  • state: empty

    Name the section

    Name what is searched

    Say which kinds of things this search covers.

    Filters

    Type
    Price

    0 results for “Name”

    Say that nothing matches

    Say what to try: spelling, fewer words, fewer filters.

    Try one of these

  • state: loading

    Name the section

    Name what is searched

    Say which kinds of things this search covers.

    Filters

    Type
    Price
    Searching…
  • state: error

    Name the section

    Name what is searched

    Say which kinds of things this search covers.

    Filters

    Type
    Price

Notes

When to use it

A results page with a search box, checkbox filters and a count. For a plain sortable list of records, app-data-table and app-data-filters are the better pair; this block is for content that people search by words.

Writing for it

- Each result has a title (80), a summary (160) and a matches list of up to 3 words. The matches must be written exactly like the facet option labels, because that is how filtering and the counts work. - Within one facet the options add up, and across facets they narrow. Make that obvious in the facet names (30), for example Type and Price, not two facets that overlap. - Give suggestions (up to 4, 40 characters each) as real searches that return something, since they only appear on the no-results state.

Watch out for

The text search runs on the results you supply, so 12 results is the ceiling and anything beyond that must be paged by your own app. The count in each option updates with the other filters and shows blank outside the filled state.

Usage

The block in a page, with its default content (long lists shortened). Every prop is in the table below.

section.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import AppSearchResults, { spec } from '@/components/klarhimmel/blocks/app-search-results';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <AppSearchResults props={spec.defaults} />
      </BlockSurface>
    </Theme>
  );
}

Props

facets are checkbox groups and results name the options they belong to (matches, in the same words as the option labels); counts are worked out from the results given. query is where the page opens; the labels build the announced count ("5 results for spa").

PropTypeDefaultDescription
eyebrowstring'Name the section'Text, up to 60 characters. Optional; empty is not rendered.
titlestring'Name what is searched'Text, up to 120 characters.
descriptionstring'Say which kinds of things this sear…'Text, up to 300 characters. Optional; empty is not rendered.
searchLabelstring'Search'Text, up to 40 characters.
searchButtonstring'Search'Text, up to 30 characters.
querystring'Name'Text, up to 80 characters.
facets{ name, options }[]2 itemsList of 1 to 3. Each item: name, options.
results{ title, summary, href, meta, matches }[]5 itemsList of up to 12. Each item: title, summary, href, meta (optional), matches.
resultsLabelstring'results'Text, up to 20 characters.
singularstring'result'Text, up to 20 characters.
forLabelstring'for'Text, up to 10 characters.
removeLabelstring'Remove filter'Text, up to 30 characters.
clearAllstring'Clear every filter'Text, up to 30 characters.
filtersLabelstring'Filters'Text, up to 30 characters.
noResults{ title, hint, suggestionsLabel }{…}Fields: title, hint, suggestionsLabel.
suggestionsstring[]3 itemsList of up to 4.
state'filled' | 'empty' | 'loading' | 'error''filled'One of 'filled', 'empty', 'loading', 'error'.
messages{ loading, error, retry }{…}Fields: loading, error, retry.
headingLevel'1' | '2'-One of '1', '2'. Optional; empty is not rendered.

Install

Installs

app-search-results
Uses
  • Badge
  • Button
  • Checkbox
  • Input
  • Skeleton
About
A results page: a search box, checkbox facets whose counts follow the other filters, active filters as removable chips, a result count that is announced when it changes, and a no-results state with suggestions.
States
Filled, empty, loading, error. The count is announced; removing a filter moves focus to it; no results offers suggestions. New project? Set it up once: /get-started/installation.