Skip to main content

View Order Block

ViewOrder is a key-value view block built on MUI with a header (title and status badge), optional subheader.

Installationโ€‹

npm install @nodeblocks/frontend-view-order-block

What You Needโ€‹

ItemWhy it matters
labels.headerTitleMain heading in the header
labels.statusTextStatus badge value; when set, the header shows ViewOrder.Status
dataOrder fields as a Record<string, ReactNode> (row keys become labels) or ReactNode[] for value-only rows
labels.status (optional)Label above the status badge (default 'Status')
statusColor (optional)Background color for the status badge
Order data lives in your app

ViewOrder does not own order state โ€” pass labels, data, and optional statusColor from your page. Object data keys become row labels; values can be strings or React nodes (links, images, layouts). Set labels.statusText to show the status badge in the header.

Code Examplesโ€‹

Live Editor
function Example() {
  const labels = {
    headerTitle: 'Order Details',
    statusText: 'Processing',
    status: 'Current Status',
  };

  const data = {
    'Order ID': '#12345',
    Customer: 'John Doe',
    Date: '2024-01-15',
    Total: '$199.99',
  };

  return (
    <ViewOrder labels={labels} statusColor="#e3f2fd" data={data} />
  );
}
Result
Loading...

Important Propsโ€‹

Core Propsโ€‹

PropTypeRequiredDefaultDescription
dataRecord<string, ReactNode> | ReactNode[]NoundefinedRow content: object keys become field labels; arrays render value-only rows
labels{ headerTitle?: string; subheaderTitle?: string; status?: string; statusText?: string }No{}Header title, optional subheader, and status badge copy (statusText enables the badge in the default header)

Content Propsโ€‹

PropTypeRequiredDefaultDescription
labels.headerTitlestringNoundefinedMain heading in ViewOrder.Header
labels.subheaderTitlestringNoundefinedSecondary line under the header (ViewOrder.Subheader)
labels.statusstringNo'Status'Label above the status badge (ViewOrder.Status)
labels.statusTextstringNoundefinedStatus badge value; shown in the default header when set
statusColorstringNoundefinedStatus badge background; falls back to theme.palette.grey[50] when unset
layout'one-column' | 'two-column'No'two-column'Row layout: stacked key/value vs side-by-side columns

Layout and Composition Propsโ€‹

PropTypeRequiredDefaultDescription
childrenBlocksOverride | ReactNodeNoundefinedCompound JSX children or function override returning blocks and blockOrder
classNamestringNoundefinedClass name on the root stack (nbb-view-order)
sxSxPropsNoundefinedMUI system styles for the root stack

ViewOrder inherits StackProps (except children). Default defaultBlockOrder: header, subheader, itemList, item, itemKey, itemValue.

Sub-component propsโ€‹

Sub-components read from context and accept the same content keys as props to override locally.

Sub-componentMain PropsInheritsBuilt on
ViewOrder.Headerlabels (headerTitle, status, statusText), children, className, sxStackPropsStack + Typography + ViewOrder.Status when statusText is set
ViewOrder.Statuslabels (status, statusText), statusColor, children, className, sxStackPropsStack + Box + Typography
ViewOrder.Subheaderlabels (subheaderTitle, headerTitle, headerActionButton), children, className, sxStackPropsStack + Typography
ViewOrder.ItemListdata, children, className, sxListPropsList (component="dl") + ViewOrder.Item rows
ViewOrder.Itemlayout, children, className, sxListItemPropsListItem
ViewOrder.Item.Keylayout, children, className, sxTypographyPropsTypography (component="dt", variant="subtitle1")
ViewOrder.Item.Valuelayout, children, className, sxTypographyPropsTypography (component="dd", variant="body2")

Default UI Blocksโ€‹

BlockBuilt onNotes
ViewOrder (root)StackColumn layout with spacing={3} (nbb-view-order)
header (ViewOrder.Header)StackheaderTitle + optional ViewOrder.Status when labels.statusText is set
subheader (ViewOrder.Subheader)StackRenders when labels.subheaderTitle or custom children is set
itemList (ViewOrder.ItemList)ListMaps data object entries or array values to key/value rows

Default root render order: header โ†’ subheader โ†’ itemList.

TypeScriptโ€‹

import * as React from 'react';
import { ViewOrder } from '@nodeblocks/frontend-view-order-block';
import type { ReactNode } from 'react';

type OrderLabels = {
headerTitle?: string;
subheaderTitle?: string;
status?: string;
statusText?: string;
};

type OrderData = Record<string, ReactNode> | ReactNode[];

export function OrderDetailView() {
const labels: OrderLabels = {
headerTitle: 'Order Details',
status: 'Current Status',
statusText: 'Processing',
};

const data: OrderData = {
'Order ID': '#12345',
Customer: 'John Doe',
Date: '2024-01-15',
Total: '$199.99',
};

return <ViewOrder labels={labels} statusColor="#e3f2fd" data={data} />;
}