Stock levels meter cards — Table block

Pro

table-stock-levels-meter-cards · for app, inventory pages

Stock levels meter cards

A small catalogue checked by its pictures: a grid of compact cards, prices in two figures and the stock bar at the foot

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/table-stock-levels-meter-cards

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import TableStockLevelsMeterCards from '@/components/trame/blocks/table/table-stock-levels-meter-cards.vue'

const props = {
title: "Workshop stock",
subtitle: "Counted this morning at 8 a.m.",
items: [
{
id: "pul-pile",
name: "Ribbed wool sweater",
sku: "PUL-COT-M",
category: "Knitwear",
image: "https://images.unsplash.com/photo-1601379327928-bedfaf9da2d0?w=400&q=80",
alt: "A stack of folded knit sweaters, from dark gray to white",
onHand: 42,
reorderAt: 15,
price: 8900,
wholesale: 3600,
tags: [
"Shop",
"Workshop"
]
},
{
id: "bon-gris",
name: "Gray knit beanie",
sku: "BON-TRI-U",
category: "Accessories",
image: "https://images.unsplash.com/photo-1667587029116-3ccb580c7858?w=400&q=80",
alt: "A gray knit beanie lying on a sheet",
onHand: 6,
reorderAt: 10,
incoming: 30,
price: 3200,
wholesale: 1100,
tags: [
"Shop"
]
}
],
search: {
placeholder: "Search for a product or SKU",
action: "stock.search"
},
filters: [
{
label: "All",
count: 6,
active: true,
action: "stock.filter",
record: {
state: "all"
}
},
{
label: "Low stock",
count: 2,
action: "stock.filter",
record: {
state: "low"
}
}
],
categories: [
{
label: "Knitwear",
count: 1,
action: "stock.category",
record: {
category: "mailles"
}
},
{
label: "Jackets",
count: 2,
action: "stock.category",
record: {
category: "vestes"
}
}
],
create: {
label: "Add a product",
action: "product.create"
},
open: "product.open",
adjust: "stock.adjust",
options: {
currency: "USD"
}
}
</script>

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

Props

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

PropTypeDescription
title*stringWordsthe page’s heading ("Stock")
subtitlestringWordsone line under the title
items*Item[]Datathe lines of the inventory, in the order the tool sorts them
searchSearchthe search field
filtersFilter[]stock states ("All", "Low stock", "Out of stock"): links the host answers
categoriesCategory[]categories to narrow the list: links the host answers
createCreatethe header’s primary action ("Add a product")
openstringActionthe page of one line (record: the item)
adjuststringActionthe page that changes one line’s stock (record: the item)
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Item items[] · 12 props
PropTypeDescription
id*string | numberDatathe record’s id in the tool that answers it
name*stringWordsthe product’s name
imagestring | nullPicturethe main picture; null or absent: the product has none yet
altstringWordswhat the main picture shows
categorystringWordsthe product’s category, e.g. "Knitwear"
sku*stringDatathe reference the inventory tool keeps ("PUL-LAI-M")
onHand*numberunits on hand now, as the inventory tool counts them
reorderAt*numberthe reorder point the merchant set: at or under it the line is low
incomingnumberunits ordered from the supplier and not yet received
pricenumberthe retail price in cents
wholesalenumberthe purchase price in cents
tagsstring[]Wordsa channel or a label ("Shop", "Market")
Search search · 3 props
PropTypeDescription
placeholder*stringWordswhat the search field says ("Search for an order")
valuestringWordsthe current query, as the address carries it
action*stringActionthe page the form sends the query to (?q=)
Filter filters[] · 5 props
PropTypeDescription
label*stringWordsthe link’s words, e.g. "Unpaid"
countnumberDatahow many records it holds, as the host counted them
activebooleantrue: this is the one shown now
action*stringActionthe page action that shows it
recordRecord<string, unknown>Datawhat the action needs (the filter’s value)
Category categories[] · 5 props
PropTypeDescription
label*stringWordsthe link’s words, e.g. "Unpaid"
countnumberDatahow many records it holds, as the host counted them
activebooleantrue: this is the one shown now
action*stringActionthe page action that shows it
recordRecord<string, unknown>Datawhat the action needs (the filter’s value)
Create create · 2 props
PropTypeDescription
label*stringWordsthe words on the button or link
action*stringActiona named action of the page
Options options · 3 props
PropTypeDescription
currencystringDesignISO 4217, EUR by default
density'comfortable' | 'compact'row height
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
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.

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, filters[], categories[], create, open, adjust
  • Reads products, inventory from your app

A table section, for app, inventory pages; it uses @lucide/vue, 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 table blocks

  • Resource list: records a team searches, sorts and acts on, one comfortable row each: orders, invoices, customers.
  • Resource totals: records whose amounts matter together: a footer with the selection count and the list’s own totals.
  • Spreadsheet grid: Edit a dense table with a frozen first column and row selection, then save the edits in one go.
  • Spreadsheet summary bar: Keep the selection count and numeric sum prominent above the editable grid, saved in one go.
  • Stage rows track cards: fewer records each needing a next step: one card per record with a status sentence, the labelled track full width and the action beside it, filters in a rail.
  • Stage rows track: many records followed at a glance (shipments, sales orders): a table whose progress column is a row of joined dots, an exception named in words.
  • Webhook deliveries log: An endpoint’s page in developer settings: a dense table of deliveries (status, event, HTTP code, time, duration), each row opening in place on its request, its response and "Retry" when it failed.
  • Webhook deliveries split: Debugging one endpoint on a wide screen: the deliveries listed on the left, the chosen one’s request, response and "Retry" beside them; on a phone the chosen one opens under its row.

All 24 table blocks