Search results tabs — Storefront block
Prostorefront-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-tabsUsage
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.
| Prop | Type | Description |
|---|---|---|
| query* | string | Datathe words the visitor typed; empty before any search |
| total | number | Datathe real number of results, all groups together |
| action* | string | Actionthe 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) |
| counts | Counts | Datathe real count of each group, when the lists below are only a first page of them |
| products | Product[] | Datathe products found, best match first |
| categories | Category[] | Datathe categories found |
| articles | Article[] | Datathe articles found |
| didYouMean | string | Dataa correction the search tool proposes for the query |
| suggestions | Suggestion[] | popular searches or categories: shown before any search and when nothing matches |
| fallback | Fallback[] | Datathe shop’s own best sellers or new arrivals, shown when nothing matches |
| openProduct | string | Actionthe page action a product opens; it receives the product |
| openCategory | string | Actionthe page action a category opens; it receives the category |
| openArticle | string | Actionthe page action an article opens; it receives the article |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Counts counts · 3 props
| Prop | Type | Description |
|---|---|---|
| products | number | how many products match |
| categories | number | how many categories match |
| articles | number | how many articles match |
Product products[] · 19 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe record’s id in the tool that answers it |
| name* | string | Wordsthe product’s name |
| price* | number | an amount in cents |
| compareAt | number | the price before the merchant’s reduction |
| currency | string | DesignISO 4217, EUR by default |
| image | string | null | Picturethe main picture; null or absent: the product has none yet |
| images | string[] | Picturea picture: a root-relative path (/media/…) or an absolute URL |
| alt | string | Wordswhat the main picture shows |
| brand | string | Wordsthe brand or maker |
| category | string | Wordsthe product’s category, e.g. "Knitwear" |
| summary | string | Wordsone short line on the product |
| badge | string | Wordsa short tag the merchant set ("New", "Handmade") |
| rating | number | the average of the shop’s own stored reviews |
| reviewCount | number | how many stored reviews the rating averages |
| available | boolean | false: sold out; true or absent: can be bought |
| stock | number | the real stock, when the merchant shows it |
| maxQuantity | number | the most one order may hold of it, as the merchant set it (one per customer, a limited run) |
| options | Option[] | the product’s options and their values, e.g. sizes |
| highlights | Highlight[] | a few key facts the merchant set, shown on the product’s card |
Option products[].options[] · 2 props
| Prop | Type | Description |
|---|---|---|
| name* | string | Wordsthe option’s name, e.g. "Size" |
| values* | string[] | Wordsits values, e.g. "S", "M", "L" |
Highlight products[].highlights[] · 2 props
| Prop | Type | Description |
|---|---|---|
| label* | string | Wordsthe property ("Material", "Capacity") |
| value* | string | Wordsits value, as the merchant states it ("Washed linen", "50 cl") |
Category categories[] · 6 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe record’s id in the tool that answers it |
| name* | string | Wordsthe category’s name |
| image | string | Picturea picture: a root-relative path (/media/…) or an absolute URL |
| alt | string | Wordswhat the category’s picture shows |
| count | number | how many products it holds |
| summary | string | Wordsone short line on the category |
Article articles[] · 9 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe record’s id in the tool that answers it |
| title* | string | Wordsthe article’s title |
| excerpt | string | Wordsa sentence or two from the article |
| image | string | Picturea picture: a root-relative path (/media/…) or an absolute URL |
| alt | string | Wordswhat the cover picture shows |
| section | string | Wordsthe section it belongs to, e.g. "Guides" |
| author | Author | who wrote it |
| date | string | Wordswhen it was published, as the site writes it |
| readingTime | string | Wordshow long it takes to read, e.g. "6 min" |
Author articles[].author · 6 props
| Prop | Type | Description |
|---|---|---|
| id | string | number | Datathe record’s id in the tool that answers it |
| name* | string | Wordsthe person’s name |
| role | string | Wordstheir role or job title |
| company | string | Wordswhere they work |
| avatar | string | Picturea picture: a root-relative path (/media/…) or an absolute URL |
| url | string | Designa page about them |
Suggestion suggestions[] · 3 props
| Prop | Type | Description |
|---|---|---|
| label* | string | Wordsa search or a category the shop offers ("Leather bags") |
| action* | string | Actionthe page action it leads to (a search or a collection) |
| record | Record<string, unknown> | Datathe record the action opens, if any |
Fallback fallback[] · 19 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe record’s id in the tool that answers it |
| name* | string | Wordsthe product’s name |
| price* | number | an amount in cents |
| compareAt | number | the price before the merchant’s reduction |
| currency | string | DesignISO 4217, EUR by default |
| image | string | null | Picturethe main picture; null or absent: the product has none yet |
| images | string[] | Picturea picture: a root-relative path (/media/…) or an absolute URL |
| alt | string | Wordswhat the main picture shows |
| brand | string | Wordsthe brand or maker |
| category | string | Wordsthe product’s category, e.g. "Knitwear" |
| summary | string | Wordsone short line on the product |
| badge | string | Wordsa short tag the merchant set ("New", "Handmade") |
| rating | number | the average of the shop’s own stored reviews |
| reviewCount | number | how many stored reviews the rating averages |
| available | boolean | false: sold out; true or absent: can be bought |
| stock | number | the real stock, when the merchant shows it |
| maxQuantity | number | the most one order may hold of it, as the merchant set it (one per customer, a limited run) |
| options | Option[] | the product’s options and their values, e.g. sizes |
| highlights | Highlight[] | a few key facts the merchant set, shown on the product’s card |
Option fallback[].options[] · 2 props
| Prop | Type | Description |
|---|---|---|
| name* | string | Wordsthe option’s name, e.g. "Size" |
| values* | string[] | Wordsits values, e.g. "S", "M", "L" |
Highlight fallback[].highlights[] · 2 props
| Prop | Type | Description |
|---|---|---|
| label* | string | Wordsthe property ("Material", "Capacity") |
| value* | string | Wordsits value, as the merchant states it ("Washed linen", "50 cl") |
Options options · 5 props
| Prop | Type | Description |
|---|---|---|
| eyebrow | string | Wordsover the title ("Search") |
| placeholder | string | Wordswhat the field says when empty ("A product, a material…") |
| fallbackTitle | string | Wordsthe title over the fallback products ("Our essentials") |
| tips | string[] | Wordsone tip when nothing matches ("Try a shorter word") |
| mood | 'inverse' | 'brand' | 'warm' | 'tint' | string | a 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).
| Member | What it is for |
|---|---|
| href | the address an action leads to, or null to hide what leads there |
| act | runs a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error } |
| can | whether the page has this action |
| money | formats a price, given in cents |
| asset | a picture’s address as your app serves it |
| Link | your router’s link component |
| cartCount | the cart badge’s number |
| cartDrawer | whether your app has a cart drawer |
| cartOpen | whether the cart drawer is open |
| label | your 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:
| Key | English | French |
|---|---|---|
| cart.added | Added to the cart | Ajouté au panier |
| grid.choose | Choose options | Choisir les options |
| grid.rating | Average rating {rating} out of 5 | Note moyenne {rating} sur 5 |
| grid.sale | Sale price | Prix réduit |
| grid.soldOut | Sold out | Épuisé |
| grid.was | Price before reduction | Prix avant réduction |
| newsletter.already | You are already subscribed. | Vous êtes déjà inscrit. |
| newsletter.done | Done: you are subscribed. | C’est noté : vous êtes inscrit. |
| newsletter.invalid | Check the email address. | Vérifiez l’adresse e-mail. |
| newsletter.tooMany | Too many attempts, try again in a moment. | Trop de tentatives, réessayez dans un moment. |
| search.articles | Articles | Articles |
| search.categories | Categories | Catégories |
| search.count0 | No results | Aucun résultat |
| search.count1 | 1 result | 1 résultat |
| search.countN | {n} results | {n} résultats |
| search.did | Did you mean | Vous cherchiez peut-être |
| search.eyebrow | Search | Recherche |
| search.fallback | Our essentials | Nos incontournables |
| search.groups | Result groups | Groupes de résultats |
| search.label | Your search | Votre recherche |
| search.none | Nothing matches “{q}” | Rien ne correspond à « {q} » |
| search.noneText | Here is how to get back on track. | Voici de quoi repartir du bon pied. |
| search.placeholder | A product, a material… | Un produit, une matière… |
| search.popular | Popular searches | Recherches fréquentes |
| search.products | Products | Produits |
| search.start | What are you looking for? | Que cherchez-vous ? |
| search.submit | Search | Rechercher |
| search.tip1 | Check the spelling or try a shorter word. | Vérifiez l’orthographe ou essayez un mot plus court. |
| search.tip2 | Try 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.tipsTitle | Tips | Pour mieux chercher |
| search.title | Results 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,articlesfrom 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.