Skip to main content

View User Block

ViewUser is a key-value view block built on MUI with a header (title and optional action button), optional subheader.

Installationโ€‹

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

What You Needโ€‹

ItemWhy it matters
labels.headerTitleMain heading in the header
dataUser fields as a Record<string, ReactNode> (row keys become labels) or ReactNode[] for value-only rows
labels.subheaderTitle (optional)Secondary line under the header (for example registration date)
labels.headerActionButton + headerAction (optional)Outlined header button label and click handler
layout (optional)one-column stacks key/value rows; two-column shows them side by side (default)
User data lives in your app

ViewUser does not own user state โ€” pass labels, data, and optional headerAction from your page. Object data keys become row labels; values can be strings or React nodes (multi-line text, links, layouts). Set labels.headerActionButton and headerAction to show the header action button with a handler.

Code Examplesโ€‹

Live Editor
function Example() {
  const labels = {
    headerTitle: 'Jane Smith',
    subheaderTitle: 'Member since Nov 22, 2023',
  };

  const data = {
    Email: 'jane.smith@example.com',
    Phone: '+1 (555) 123-4567',
    Role: 'Frontend Engineer',
    Location: 'San Francisco, CA',
  };

  return <ViewUser labels={labels} 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; headerActionButton?: string; subheaderTitle?: string }No{}Header title, optional action button label, and subheader copy

Content Propsโ€‹

PropTypeRequiredDefaultDescription
labels.headerTitlestringNoundefinedMain heading in ViewUser.Header
labels.subheaderTitlestringNoundefinedSecondary line under the header (ViewUser.Subheader)
labels.headerActionButtonstringNoundefinedLabel for the outlined header button; shown when labels.headerActionButton or headerAction is set (or passed on ViewUser.HeaderActionButton)
headerAction() => voidNoundefinedInvoked when the default header action button is clicked
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-user)
sxSxPropsNoundefinedMUI system styles for the root stack (default render includes margin: 'auto')

ViewUser 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
ViewUser.Headerlabels (headerTitle, headerActionButton), headerAction, children, className, sxStackPropsStack + Typography + optional ViewUser.HeaderActionButton
ViewUser.HeaderActionButtonlabels (headerActionButton), headerAction, children, className, onClickButtonPropsButton (variant="outlined", size="medium")
ViewUser.Subheaderlabels (subheaderTitle, headerTitle, headerActionButton), children, className, sxStackPropsStack + Typography
ViewUser.ItemListdata, children, className, sxListPropsList (component="dl") + ViewUser.Item rows
ViewUser.Itemlayout, children, className, sxListItemPropsListItem
ViewUser.Item.Keylayout, children, className, sxTypographyPropsTypography (component="dt", variant="subtitle1")
ViewUser.Item.Valuelayout, children, className, sxTypographyPropsTypography (component="dd", variant="body2")

Default UI Blocksโ€‹

BlockBuilt onNotes
ViewUser (root)StackColumn layout with spacing={3}, margin: 'auto' (nbb-view-user)
header (ViewUser.Header)StackRenders when labels.headerTitle, labels.headerActionButton, or custom children is set; includes ViewUser.HeaderActionButton when headerAction or labels.headerActionButton is set
subheader (ViewUser.Subheader)StackRenders when labels.subheaderTitle or custom children is set
itemList (ViewUser.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 { ViewUser } from '@nodeblocks/frontend-view-user-block';
import type { ReactNode } from 'react';

type UserLabels = {
headerTitle?: string;
headerActionButton?: string;
subheaderTitle?: string;
};

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

export function UserDetailView() {
const labels: UserLabels = {
headerTitle: 'Jane Smith',
subheaderTitle: 'Member since Nov 22, 2023',
headerActionButton: 'Edit profile',
};

const data: UserData = {
Email: 'jane.smith@example.com',
Phone: '+1 (555) 123-4567',
Role: 'Frontend Engineer',
};

return (
<ViewUser
labels={labels}
data={data}
headerAction={() => {
/* navigate or open edit dialog */
}}
/>
);
}