Tally UI

ProductStockBadge

Visual stock status indicator with colored dot and label

Import

import { ProductStockBadge } from '@tallyui/components';

Usage

<ProductStockBadge doc={productDocument} />
<ProductStockBadge doc={productDocument} showQuantity />

Renders a pill-shaped badge with status-appropriate colors:

  • In Stock — bg-success/15 text-success
  • Out of Stock — bg-destructive/15 text-destructive
  • On Backorder — bg-warning/15 text-warning
  • Unknown — bg-muted/15 text-muted-foreground

Props

PropTypeDefaultDescription
docanyrequiredRxDB product document
showQuantitybooleanfalseShow quantity alongside status
showAsOfbooleantrueShow when reconciled stock was last confirmed
classNamestring—Override badge container styles

Reconciled stock

When the connector reconciles stock (reconcile.stock), pass the overlay and its "as of" time to ConnectorProvider. The badge then shows reconciled stock, followed by · as of 14:05.

const overlay = useObservable(stockOverlay$(db.stock_levels));
const asOf = useObservable(stockOverlayAsOf$(db.stock_levels));

<ConnectorProvider connector={connector} stockOverlay={overlay} stockOverlayAsOf={asOf}>
  <ProductStockBadge doc={productDocument} />
</ConnectorProvider>

stockOverlay$ and stockOverlayAsOf$ come from @tallyui/pos; useObservable stands for any hook that subscribes to an observable.

Trait mapping

ConnectorStock status sourceQuantity source
WooCommercedoc.stock_statusdoc.stock_quantity
MedusaDerived from variant.manage_inventory / inventory_quantitydoc.variants[0].inventory_quantity
ShopifyDerived from variant.inventory_management / inventory_policy / inventory_quantitydoc.variants[0].inventory_quantity
Vendurevariant.stockLevel string (IN_STOCK, OUT_OF_STOCK, LOW_STOCK)doc.variants[0].stockOnHand (Admin API only)

Live demo