Record tabbed — Search block
Prosearch-record-tabbed · for app, search pages
Record tabbed
People who know what they want: tabs of the kinds with their counts above one flat list of mixed hits, each with its kind’s sign, its reference, the title with the matched words, a snippet and where it lives.
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/search-record-tabbedUsage
Its demo data, shortened (Using blocks).
<script setup lang="ts">
import SearchRecordTabbed from '@/components/trame/blocks/search/search-record-tabbed.vue'
const props = {
title: "Search",
query: "launch",
types: [
{
key: "project",
label: "Projects",
count: 3,
icon: "project"
},
{
key: "task",
label: "Tasks",
count: 24,
icon: "task"
}
],
rows: [
{
id: "p-14",
type: "project",
title: "Spring launch",
code: "SPR",
snippet: "Everything for the spring launch: the new pricing page, the onboarding emails and the press kit.",
place: [
"Marketing"
],
meta: "18 open tasks",
marks: {
title: [
[
7,
13
]
],
snippet: [
[
26,
32
]
]
}
},
{
id: "p-9",
type: "project",
title: "Mobile app launch",
code: "MOB",
snippet: "Store listings, the beta group and the launch week plan for iOS and Android.",
place: [
"Product"
],
meta: "7 open tasks",
marks: {
title: [
[
11,
17
]
],
snippet: [
[
39,
45
]
]
}
}
],
total: 38,
search: "search",
more: "search.more",
typeLink: "search.type",
open: "record.open"
}
</script>
<template>
<SearchRecordTabbed v-bind="props" />
</template>Props
Each prop says who changes it: Words, Picture, Action, Design, Data.* required.
| Prop | Type | Description |
|---|---|---|
| title | string | Wordsthe page’s heading ("Search") |
| query* | string | Wordsthe words searched, as the person typed them; shown in the field and the summary, empty before any search |
| types* | Type[] | the kinds of record the search covers, in the order shown, each with its count for this query |
| type | string | Datathe key of the kind the results are narrowed to (the address’s `type`); all kinds when absent |
| rows* | Row[] | Datathe hits, best match first; with `type`, only that kind’s; may be empty when nothing matches |
| total | number | Datahow many hits there are in all for this query (or this kind); the sum of the kinds’ counts when absent |
| after | string | number | Datathe cursor of the next page of hits, when there is one |
| search | string | Actionthe search page: the field is a GET form to href(search) sending `q` (and `type` once narrowed), so it works without script; with a host that answers queries, the hits update as the person types, through query(search, { q }), whose `items` are hits |
| more | string | Actionthe next page of hits: query(more, { after }) appends its `items`; without a host that answers queries, a link to href(more, { after, q, type }) |
| typeLink | string | Actionthe results narrowed to one kind: href(typeLink, { type, q }) is a kind’s address, and href(typeLink, { q }) every kind’s; without it the kinds are shown as words |
| open* | string | Actionthe page of one hit: href(open, hit) receives the whole hit, its `type` and `id` included |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Type types[] · 4 props
| Prop | Type | Description |
|---|---|---|
| key* | string | Designthe kind’s key, as hits name it in `type` ("task") |
| label* | string | Wordsthe kind in words, plural ("Tasks") |
| count* | number | Datahow many records of this kind match, as the host counted them |
| icon | 'project' | 'task' | 'document' | 'person' | 'company' | 'deal' | 'contact' | 'message' | 'file' | 'event' | 'ticket' | 'invoice' | 'folder' | 'page' | Designthe sign drawn beside the kind and its hits, from the block’s set; a neutral sign when absent |
Row rows[] · 8 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe record’s id in the app |
| type* | string | Designthe key of the record’s kind, one of `types[].key` ("task") |
| title* | string | Wordsthe record’s name as the app shows it ("Launch checklist") |
| code | string | Wordsthe record’s short reference, if the app has one ("WEB-142") |
| snippet | string | Wordsa passage of the record around the matched words, plain text ("…the launch checklist is shared with…") |
| place | string[] | Wordswhere the record lives, outermost first: a breadcrumb in words |
| meta | string | Wordsone short fact about it ("Updated 2 days ago", "Due Nov 12") |
| marks | Marks | where the searched words were found, as offsets the search engine answered; never HTML |
Marks rows[].marks · 2 props
| Prop | Type | Description |
|---|---|---|
| title | unknown[] | the matched stretches of the title |
| snippet | unknown[] | the matched stretches of the snippet |
Options options · 1 props
| Prop | Type | Description |
|---|---|---|
| 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 } |
| query | a live read: a quick search, « see more » |
| can | whether the page has this action |
| 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 |
|---|---|---|
| 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. |
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
- No motion; still under reduced motion
- Real buttons and links, a visible focus
- Asks your app through actions:
search,more,link,link - Reads
rowsfrom your app
A search section, for app, search pages; it uses @lucide/vue, @vueuse/core, class-variance-authority, clsx, reka-ui, tailwind-merge.
Built with
The components this block is made of; each one installs on its own too.
More search blocks
- Command menu dialog: the app’s palette: a quiet trigger showing the shortcut, the panel opens over the page.
- Filter builder rows: Above a data table or in a filter panel: a stack of condition rows (field, operator, value) under "Match all / any", with "Add condition", "Apply" and "Save view" at the foot.
- Filter builder sentence: When the filter should read as plain words ("Show deals where stage is Won and amount is greater than 10000"): each part is a token that opens a small popover to change it.
- Inline commands open panel: the panel open in the page, for a search page or the app’s empty search state.