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
| Part | File | Does |
|---|---|---|
| Search | Search.vue | Groups all parts of the search: a field whose panel offers results, suggestions and a "Search for" row. |
| SearchEmpty | SearchEmpty.vue | A line of text in the panel, such as "No results for …"; the shop decides when it shows. |
| SearchGroup | SearchGroup.vue | A headed section of the panel: products, categories, brands, or suggestions. |
| SearchHighlight | SearchHighlight.vue | Text with every match of the search terms in bold; the terms default to the typed query. |
| SearchInput | SearchInput.vue | The search field: a search icon, the input, and a button that clears it. |
| SearchItem | SearchItem.vue | One row of the panel that opens something: a link, so middle-click and open-in-new-tab work. |
| SearchLoading | SearchLoading.vue | Skeleton rows and "Searching…" while the shop's search answers; shows only while Search is loading. |
| SearchOverlay | SearchOverlay.vue | Shows the search in an overlay: near the top on wide screens, full screen on phones with a Cancel button. |
| SearchOverlayTrigger | SearchOverlayTrigger.vue | Opens the search overlay; focus returns to it when the overlay closes, also after a click that never focused it. |
| SearchQuery | SearchQuery.vue | The first row while the shopper types: "Search for …", which submits the query to the results page. |
| SearchResults | SearchResults.vue | The panel of results, suggestions and the "Search for" row, under the field or inside the overlay. |
| SearchTag | SearchTag.vue | A 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
Groups all parts of the search: a field whose panel offers results, suggestions and a "Search for" row.
Props 5
| Prop | Type | Default | |
|---|---|---|---|
| loading | boolean | false | |
| |||
| openOnFocus | boolean | true | |
| |||
| loop | boolean | true | |
| |||
| query | string | '' | |
| |||
| open | boolean | false | |
| |||
Events 4
| Event | Payload | |
|---|---|---|
| update:open | value: boolean | |
| ||
| select | value: unknown | |
| ||
| submit | query: string | |
| ||
| update:query | value: string | |
| ||
Slots 1
| Slot | Slot props | |
|---|---|---|
| default | { query: string; open: boolean; } | |
| ||
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'56import { computed, ref } from 'vue'7import { Button } from '@/components/ui/button'8import { Price } from '@/components/ui/price'9import {10Search,11SearchEmpty,12SearchGroup,13SearchHighlight,14SearchInput,15SearchItem,16SearchOverlay,17SearchOverlayTrigger,18SearchQuery,19SearchResults,20SearchTag,21} from '@/components/ui/search'2223const 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']3132const query = ref('')33const products = computed(() => {34const text = query.value.trim().toLowerCase()35return text36? catalog.filter((product) => product.name.toLowerCase().includes(text))37: []38})39</script>4041<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<Button48variant="ghost"49color="neutral"50size="icon-md"51aria-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<SearchTag63v-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<SearchItem72v-for="product in products"73:key="product.name"74:value="product.name"75href="#">76<SearchHighlight77:text="product.name"78class="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>