search

Search

A search field whose panel offers products, categories and suggestions while the shopper types, with a "Search for" row that submits; inline under the field or in an overlay.

Parts

PartFileDoes
SearchSearch.vueGroups all parts of the search: a field whose panel offers results, suggestions and a "Search for" row.
SearchEmptySearchEmpty.vueA line of text in the panel, such as "No results for …"; the shop decides when it shows.
SearchGroupSearchGroup.vueA headed section of the panel: products, categories, brands, or suggestions.
SearchHighlightSearchHighlight.vueText with every match of the search terms in bold; the terms default to the typed query.
SearchInputSearchInput.vueThe search field: a search icon, the input, and a button that clears it.
SearchItemSearchItem.vueOne row of the panel that opens something: a link, so middle-click and open-in-new-tab work.
SearchLoadingSearchLoading.vueSkeleton rows and "Searching…" while the shop's search answers; shows only while Search is loading.
SearchOverlaySearchOverlay.vueShows the search in an overlay: near the top on wide screens, full screen on phones with a Cancel button.
SearchOverlayTriggerSearchOverlayTrigger.vueOpens the search overlay; focus returns to it when the overlay closes, also after a click that never focused it.
SearchQuerySearchQuery.vueThe first row while the shopper types: "Search for …", which submits the query to the results page.
SearchResultsSearchResults.vueThe panel of results, suggestions and the "Search for" row, under the field or inside the overlay.
SearchTagSearchTag.vueA suggested search, drawn as a tag; opening it runs that search.

Anatomy

<Search>
  <SearchInput />
  <SearchResults>
    <SearchGroup>
      <SearchTag />
      <SearchItem>
        <SearchHighlight />
      </SearchItem>
    </SearchGroup>
    <SearchQuery />
    <SearchLoading />
    <SearchEmpty />
    <SearchTag />
  </SearchResults>
</Search>

Styling

All of Search’s styles live in search.json. New to styling in Frontic UI? How styling works →

Install

Installs with it
skeleton
npm packages
@lucide/vue
class-variance-authority
reka-ui

Built from

API reference

SearchEmpty.vue

SearchGroup.vue

SearchHighlight.vue

SearchInput.vue

SearchItem.vue

SearchLoading.vue

SearchOverlay.vue

SearchOverlayTrigger.vue

SearchQuery.vue

SearchResults.vue

SearchTag.vue
Search

Overlay

1<!-- SPDX-License-Identifier: FSL-1.1-MIT -->2<!-- Frontic UI © Frontic · ui.frontic.com/license -->3<script setup lang="ts">4import { SearchIcon } from '@lucide/vue'5 6import { computed, ref } from 'vue'7import { Button } from '@/components/ui/button'8import { Price } from '@/components/ui/price'9import {10  Search,11  SearchEmpty,12  SearchGroup,13  SearchHighlight,14  SearchInput,15  SearchItem,16  SearchOverlay,17  SearchOverlayTrigger,18  SearchQuery,19  SearchResults,20  SearchTag,21} from '@/components/ui/search'22 23const eur = (amount: number) => ({ amount, currency: 'EUR' })24const catalog = [25  { name: 'Frost Escape Parka', price: eur(14900) },26  { name: 'Blizzard Defender', price: eur(12600) },27  { name: 'Snowflake Ski Goggles', price: eur(12700) },28  { name: 'TrailMaster 22', price: eur(14100) },29]30const suggestions = ['parka', 'goggles', 'TrailMaster']31 32const query = ref('')33const products = computed(() => {34  const text = query.value.trim().toLowerCase()35  return text36    ? catalog.filter((product) => product.name.toLowerCase().includes(text))37    : []38})39</script>40 41<template>42  <SearchOverlay>43    <template #trigger>44      <div class="flex w-md max-w-full items-center justify-between gap-4">45        <span>Basecamp</span>46        <SearchOverlayTrigger as-child>47          <Button48            variant="ghost"49            color="neutral"50            size="icon-md"51            aria-label="Search">52            <SearchIcon data-icon />53          </Button>54        </SearchOverlayTrigger>55      </div>56    </template>57    <Search v-model:query="query">58      <SearchInput placeholder="Search jackets, goggles, packs" />59      <SearchResults>60        <SearchGroup v-if="!query.trim()" heading="Popular searches">61          <div class="flex flex-wrap gap-2 px-3 pb-3">62            <SearchTag63              v-for="suggestion in suggestions"64              :key="suggestion"65              :query="suggestion" />66          </div>67        </SearchGroup>68        <template v-else>69          <SearchQuery />70          <SearchGroup v-if="products.length" heading="Products">71            <SearchItem72              v-for="product in products"73              :key="product.name"74              :value="product.name"75              href="#">76              <SearchHighlight77                :text="product.name"78                class="min-w-0 flex-1 truncate" />79              <Price :price="product.price" align="end" />80            </SearchItem>81          </SearchGroup>82          <SearchEmpty v-else>No results for "{{ query }}".</SearchEmpty>83        </template>84      </SearchResults>85    </Search>86  </SearchOverlay>87</template>
State