Stock levels meter cards — Table block
Protable-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-cardsUsage
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.
| Prop | Type | Description |
|---|---|---|
| title* | string | Wordsthe page’s heading ("Stock") |
| subtitle | string | Wordsone line under the title |
| items* | Item[] | Datathe lines of the inventory, in the order the tool sorts them |
| search | Search | the search field |
| filters | Filter[] | stock states ("All", "Low stock", "Out of stock"): links the host answers |
| categories | Category[] | categories to narrow the list: links the host answers |
| create | Create | the header’s primary action ("Add a product") |
| open | string | Actionthe page of one line (record: the item) |
| adjust | string | Actionthe page that changes one line’s stock (record: the item) |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Item items[] · 12 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe record’s id in the tool that answers it |
| name* | string | Wordsthe product’s name |
| image | string | null | Picturethe main picture; null or absent: the product has none yet |
| alt | string | Wordswhat the main picture shows |
| category | string | Wordsthe product’s category, e.g. "Knitwear" |
| sku* | string | Datathe reference the inventory tool keeps ("PUL-LAI-M") |
| onHand* | number | units on hand now, as the inventory tool counts them |
| reorderAt* | number | the reorder point the merchant set: at or under it the line is low |
| incoming | number | units ordered from the supplier and not yet received |
| price | number | the retail price in cents |
| wholesale | number | the purchase price in cents |
| tags | string[] | Wordsa channel or a label ("Shop", "Market") |
Search search · 3 props
| Prop | Type | Description |
|---|---|---|
| placeholder* | string | Wordswhat the search field says ("Search for an order") |
| value | string | Wordsthe current query, as the address carries it |
| action* | string | Actionthe page the form sends the query to (?q=) |
Filter filters[] · 5 props
| Prop | Type | Description |
|---|---|---|
| label* | string | Wordsthe link’s words, e.g. "Unpaid" |
| count | number | Datahow many records it holds, as the host counted them |
| active | boolean | true: this is the one shown now |
| action* | string | Actionthe page action that shows it |
| record | Record<string, unknown> | Datawhat the action needs (the filter’s value) |
Category categories[] · 5 props
| Prop | Type | Description |
|---|---|---|
| label* | string | Wordsthe link’s words, e.g. "Unpaid" |
| count | number | Datahow many records it holds, as the host counted them |
| active | boolean | true: this is the one shown now |
| action* | string | Actionthe page action that shows it |
| record | Record<string, unknown> | Datawhat the action needs (the filter’s value) |
Create create · 2 props
| Prop | Type | Description |
|---|---|---|
| label* | string | Wordsthe words on the button or link |
| action* | string | Actiona named action of the page |
Options options · 3 props
| Prop | Type | Description |
|---|---|---|
| currency | string | DesignISO 4217, EUR by default |
| density | 'comfortable' | 'compact' | row height |
| 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 |
|---|---|---|
| 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,filters[],categories[],create,open,adjust - Reads
products,inventoryfrom 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.