Skip to main content

Error Block

ErrorBlock is a centered error status layout built on MUI.

Installation​

npm install @nodeblocks/frontend-error-block@0.3.1

What You Need​

ItemWhy it matters
errorTitleMain heading shown in the title block
subtitleSupporting message below the title
actionHrefDestination URL for the primary action button
actionTextLabel for the primary action button
titleErrorCode (optional)Short code or label shown above the title (for example, Error 404)
Static content props

ErrorBlock does not manage message state. Pass copy and links directly as props.

Code Examples​

Live Editor
function Example() {
  return (
    <ErrorBlock
      errorTitle="Page not found"
      subtitle="Page you're trying to reach was not found or no longer exists."
      actionHref="#home"
      actionText="Back to Home"
    />
  );
}
Result
Loading...

Important Props​

Core Props​

PropTypeRequiredDefaultDescription
errorTitlestringYes-Main error heading
subtitlestringYes-Supporting message below the title
actionHrefstringYes-href for the primary action button
actionTextstringYes-Label for the primary action button

Content Props​

PropTypeRequiredDefaultDescription
titleErrorCodestringNo-Optional code or label rendered above errorTitle

Layout and Composition Props​

PropTypeRequiredDefaultDescription
childrenBlocksOverride | ReactNodeNo-Compound sub-components or a block override function
spacingStackProps['spacing']No4Vertical spacing between rendered blocks
blockSpacingBeforeRecord<string, StackProps['spacing']>No{ title: { xs: 2, sm: 3 }, action: { xs: 4, sm: 6 } }Adds top margin before specific blocks (icon, title, subtitle, action)
classNamestringNo-Class name for the root container (also applies nbb-error-block)
sxSxPropsNo-MUI system styles for the root Stack

ErrorBlock inherits StackProps (except children), so standard layout props are supported on the root. Default block order is icon → title → subtitle → action.

Sub-components read values from context and accept partial MUI props:

  • ErrorBlock.Icon — ErrorOutlined props (sx, className, …)
  • ErrorBlock.Title — Typography props plus optional titleErrorCode, errorTitle, or children
  • ErrorBlock.Subtitle — Typography props plus optional subtitle or children
  • ErrorBlock.Action — Button props plus optional actionHref, actionText, or children

Default UI Blocks​

BlockBuilt onNotes
ErrorBlock (root)StackCentered container with maxWidth: 350, textAlign="center", and default spacing={4}
ErrorBlock.IconErrorOutlined48px icon using secondary.main
ErrorBlock.TitleTypography (variant="h4")Renders titleErrorCode (when set) above the title
ErrorBlock.SubtitleTypographySubtitle copy from subtitle
ErrorBlock.ActionButton (variant="contained", size="medium")Navigates to actionHref

TypeScript​

import {ErrorBlock} from '@nodeblocks/frontend-error-block';
import type {ComponentProps} from 'react';

type ErrorBlockProps = ComponentProps<typeof ErrorBlock>;

function NotFoundError(props: Pick<ErrorBlockProps, 'actionHref' | 'actionText'>) {
return (
<ErrorBlock
errorTitle="Page not found"
subtitle="The page you requested does not exist or was moved."
titleErrorCode="Error 404"
{...props}
/>
);
}