Search results tabs — Storefront block

Pro

storefront-search-results-tabs · for search pages

Search results tabs

One group at a time (products, categories, articles) behind a tab row with real counts: for shops where products are what people want and the rest is a side road

Documentation

Installation

One command copies the block into your project with the shadcn CLI (the registry is set once: Installation).

pnpm dlx shadcn-vue@latest add @trame/storefront-search-results-tabs

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import StorefrontSearchResultsTabs from '@/components/trame/blocks/storefront/storefront-search-results-tabs.vue'

const props = {
query: "hiking",
action: "search",
total: 56,
counts: {
products: 38,
categories: 3,
articles: 2
},
products: [
{
id: "p1",
name: "Trail Path hiking shoes",
price: 12900,
image: "https://images.unsplash.com/photo-1575987116913-e96e7d490b8a?w=1600&q=80",
images: [
"https://images.unsplash.com/photo-1575987116913-e96e7d490b8a?w=1600&q=80",
"https://images.unsplash.com/photo-1600100315760-ac46b65f6fdd?w=1600&q=80"
],
alt: "Tan leather walking shoes resting on a red rock",
brand: "Atelier Cime",
badge: "New"
},
{
id: "p2",
name: "Hiking backpack 22 L",
price: 9500,
compareAt: 11900,
image: "https://images.unsplash.com/photo-1602845860431-35374f24f48d?w=1600&q=80",
images: [
"https://images.unsplash.com/photo-1602845860431-35374f24f48d?w=1600&q=80",
"https://images.unsplash.com/photo-1678606460531-7ce3b23242a3?w=1600&q=80"
],
alt: "A mustard canvas backpack with leather straps, lying in the grass",
brand: "Atelier Cime"
}
],
categories: [
{
id: "chaussures",
name: "Hiking shoes",
count: 18,
image: "https://images.unsplash.com/photo-1600100315760-ac46b65f6fdd?w=1600&q=80",
alt: "A trail shoe on a rock"
},
{
id: "sacs",
name: "Hiking bags",
count: 9,
image: "https://images.unsplash.com/photo-1678606460531-7ce3b23242a3?w=1600&q=80",
alt: "A hiker seen from behind, wearing a backpack"
}
],
articles: [
{
id: "a1",
title: "Choosing hiking shoes: five questions to ask yourself",
excerpt: "Terrain, distance, pack weight: what to know before you try on a pair, and how to test it in the store.",
section: "Advice",
date: "September 12",
image: "https://images.unsplash.com/photo-1600100315778-850119b19220?w=1600&q=80",
alt: "Legs in walking shoes on a rock facing the mountains"
},
{
id: "a2",
title: "A two-day hike with 18 lb on your back",
excerpt: "Our gear list, weighed down to the ounce, for nights in a hut or a tent.",
section: "Trail journal",
date: "August 3"
}
],
openProduct: "product",
openCategory: "collection",
openArticle: "article",
suggestions: [
{
label: "Backpacks",
action: "collection",
record: {
id: "sacs"
}
},
{
label: "Trail shoes",
action: "collection",
record: {
id: "baskets"
}
}
]
}
</script>

<template>
<StorefrontSearchResultsTabs v-bind="props" />
</template>

Props

Each prop says who changes it: Words, Picture, Action, Design, Data.* required.

PropTypeDescription
query*stringDatathe words the visitor typed; empty before any search
totalnumberDatathe real number of results, all groups together
action*stringActionthe page action of the search page: the field is a GET form to its address, parameter "q"
tab'products' | 'categories' | 'articles'Datathe group shown, with the "tabs" variant (the "tab" parameter of the address)
countsCountsDatathe real count of each group, when the lists below are only a first page of them
productsProduct[]Datathe products found, best match first
categoriesCategory[]Datathe categories found
articlesArticle[]Datathe articles found
didYouMeanstringDataa correction the search tool proposes for the query
suggestionsSuggestion[]popular searches or categories: shown before any search and when nothing matches
fallbackFallback[]Datathe shop’s own best sellers or new arrivals, shown when nothing matches
openProductstringActionthe page action a product opens; it receives the product
openCategorystringActionthe page action a category opens; it receives the category
openArticlestringActionthe page action an article opens; it receives the article
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Counts counts · 3 props
PropTypeDescription
productsnumberhow many products match
categoriesnumberhow many categories match
articlesnumberhow many articles match
Product products[] · 19 props
PropTypeDescription
id*string | numberDatathe record’s id in the tool that answers it
name*stringWordsthe product’s name
price*numberan amount in cents
compareAtnumberthe price before the merchant’s reduction
currencystringDesignISO 4217, EUR by default
imagestring | nullPicturethe main picture; null or absent: the product has none yet
imagesstring[]Picturea picture: a root-relative path (/media/…) or an absolute URL
altstringWordswhat the main picture shows
brandstringWordsthe brand or maker
categorystringWordsthe product’s category, e.g. "Knitwear"
summarystringWordsone short line on the product
badgestringWordsa short tag the merchant set ("New", "Handmade")
ratingnumberthe average of the shop’s own stored reviews
reviewCountnumberhow many stored reviews the rating averages
availablebooleanfalse: sold out; true or absent: can be bought
stocknumberthe real stock, when the merchant shows it
maxQuantitynumberthe most one order may hold of it, as the merchant set it (one per customer, a limited run)
optionsOption[]the product’s options and their values, e.g. sizes
highlightsHighlight[]a few key facts the merchant set, shown on the product’s card
Option products[].options[] · 2 props
PropTypeDescription
name*stringWordsthe option’s name, e.g. "Size"
values*string[]Wordsits values, e.g. "S", "M", "L"
Highlight products[].highlights[] · 2 props
PropTypeDescription
label*stringWordsthe property ("Material", "Capacity")
value*stringWordsits value, as the merchant states it ("Washed linen", "50 cl")
Category categories[] · 6 props
PropTypeDescription
id*string | numberDatathe record’s id in the tool that answers it
name*stringWordsthe category’s name
imagestringPicturea picture: a root-relative path (/media/…) or an absolute URL
altstringWordswhat the category’s picture shows
countnumberhow many products it holds
summarystringWordsone short line on the category
Article articles[] · 9 props
PropTypeDescription
id*string | numberDatathe record’s id in the tool that answers it
title*stringWordsthe article’s title
excerptstringWordsa sentence or two from the article
imagestringPicturea picture: a root-relative path (/media/…) or an absolute URL
altstringWordswhat the cover picture shows
sectionstringWordsthe section it belongs to, e.g. "Guides"
authorAuthorwho wrote it
datestringWordswhen it was published, as the site writes it
readingTimestringWordshow long it takes to read, e.g. "6 min"
Author articles[].author · 6 props
PropTypeDescription
idstring | numberDatathe record’s id in the tool that answers it
name*stringWordsthe person’s name
rolestringWordstheir role or job title
companystringWordswhere they work
avatarstringPicturea picture: a root-relative path (/media/…) or an absolute URL
urlstringDesigna page about them
Suggestion suggestions[] · 3 props
PropTypeDescription
label*stringWordsa search or a category the shop offers ("Leather bags")
action*stringActionthe page action it leads to (a search or a collection)
recordRecord<string, unknown>Datathe record the action opens, if any
Fallback fallback[] · 19 props
PropTypeDescription
id*string | numberDatathe record’s id in the tool that answers it
name*stringWordsthe product’s name
price*numberan amount in cents
compareAtnumberthe price before the merchant’s reduction
currencystringDesignISO 4217, EUR by default
imagestring | nullPicturethe main picture; null or absent: the product has none yet
imagesstring[]Picturea picture: a root-relative path (/media/…) or an absolute URL
altstringWordswhat the main picture shows
brandstringWordsthe brand or maker
categorystringWordsthe product’s category, e.g. "Knitwear"
summarystringWordsone short line on the product
badgestringWordsa short tag the merchant set ("New", "Handmade")
ratingnumberthe average of the shop’s own stored reviews
reviewCountnumberhow many stored reviews the rating averages
availablebooleanfalse: sold out; true or absent: can be bought
stocknumberthe real stock, when the merchant shows it
maxQuantitynumberthe most one order may hold of it, as the merchant set it (one per customer, a limited run)
optionsOption[]the product’s options and their values, e.g. sizes
highlightsHighlight[]a few key facts the merchant set, shown on the product’s card
Option fallback[].options[] · 2 props
PropTypeDescription
name*stringWordsthe option’s name, e.g. "Size"
values*string[]Wordsits values, e.g. "S", "M", "L"
Highlight fallback[].highlights[] · 2 props
PropTypeDescription
label*stringWordsthe property ("Material", "Capacity")
value*stringWordsits value, as the merchant states it ("Washed linen", "50 cl")
Options options · 5 props
PropTypeDescription
eyebrowstringWordsover the title ("Search")
placeholderstringWordswhat the field says when empty ("A product, a material…")
fallbackTitlestringWordsthe title over the fallback products ("Our essentials")
tipsstring[]Wordsone tip when nothing matches ("Try a shorter word")
mood'inverse' | 'brand' | 'warm' | 'tint' | stringa band of the page that redefines the theme surfaces inside it
What it asks your app for

The block never knows your app: it asks it, through one context provided once, where its links lead, what its actions do, how a price reads and which words to say (The host context).

MemberWhat it is for
hrefthe address an action leads to, or null to hide what leads there
actruns a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error }
canwhether the page has this action
moneyformats a price, given in cents
asseta picture’s address as your app serves it
Linkyour router’s link component
cartCountthe cart badge’s number
cartDrawerwhether your app has a cart drawer
cartOpenwhether the cart drawer is open
labelyour word for an interface key, or undefined to keep the block’s own

The words it says itself, in English and French; label(key) replaces any of them:

KeyEnglishFrench
cart.addedAdded to the cartAjouté au panier
grid.chooseChoose optionsChoisir les options
grid.ratingAverage rating {rating} out of 5Note moyenne {rating} sur 5
grid.saleSale pricePrix réduit
grid.soldOutSold outÉpuisé
grid.wasPrice before reductionPrix avant réduction
newsletter.alreadyYou are already subscribed.Vous êtes déjà inscrit.
newsletter.doneDone: you are subscribed.C’est noté : vous êtes inscrit.
newsletter.invalidCheck the email address.Vérifiez l’adresse e-mail.
newsletter.tooManyToo many attempts, try again in a moment.Trop de tentatives, réessayez dans un moment.
search.articlesArticlesArticles
search.categoriesCategoriesCatégories
search.count0No resultsAucun résultat
search.count11 result1 résultat
search.countN{n} results{n} résultats
search.didDid you meanVous cherchiez peut-être
search.eyebrowSearchRecherche
search.fallbackOur essentialsNos incontournables
search.groupsResult groupsGroupes de résultats
search.labelYour searchVotre recherche
search.noneNothing matches “{q}”Rien ne correspond à « {q} »
search.noneTextHere is how to get back on track.Voici de quoi repartir du bon pied.
search.placeholderA product, a material…Un produit, une matière…
search.popularPopular searchesRecherches fréquentes
search.productsProductsProduits
search.startWhat are you looking for?Que cherchez-vous ?
search.submitSearchRechercher
search.tip1Check the spelling or try a shorter word.Vérifiez l’orthographe ou essayez un mot plus court.
search.tip2Try a material, a use or a category rather than an exact name.Cherchez une matière, un usage ou une catégorie plutôt qu’un nom exact.
search.tipsTitleTipsPour mieux chercher
search.titleResults for “{q}”Résultats pour « {q} »

Features

  • Every word in the server HTML
  • Same markup in Vue and React
  • Theme tokens only: every theme, light and dark
  • Shows what you give it, invents nothing
  • Subtle motion: one short reveal; still under reduced motion
  • Real buttons and links, a visible focus
  • Asks your app through actions: action, suggestions[], openProduct, openCategory, openArticle
  • Reads products, categories, articles from your app

A storefront section, for search pages; it uses @lucide/vue, class-variance-authority, clsx, reka-ui, tailwind-merge.

More storefront blocks

  • Search landing suggest: a large field over a live suggestions panel, the popular searches and the products narrowing as the visitor types: a large catalogue with a precise vocabulary.
  • Search panel side sheet: a narrow sheet from the right edge, popular searches as chips and products as small text-first cards: a shop whose header search should not cover the page.
  • Search panel top sheet: a wide band under the header, the field across the width, popular searches as a column of words beside product tiles: a large catalogue.
  • Search panel: the same content in a compact panel under the header: a search that opens from the header.
  • Seconds savings table: a table of each second against its price new, with the saving: a shop that sells many seconds and wants them compared.
  • Service glossary: the terms a service uses, each with its meaning and price: a repair glossary, a duty glossary.
  • Shared list with comments: a list kept by several people, with who added what and the comments: a household, a gift list.
  • Shared list with progress: a gift list shared with guests (wedding, birth, moving in): what is wanted, how many are already given, and "Give" on each, with the list’s progress beside.

All 409 storefront blocks