Skip to main content

Settings Block

Settings is a settings menu layout built on MUI, with clickable rows for account and preference actions.

Installationโ€‹

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

What You Needโ€‹

ItemWhy it matters
settingsTitleHeading shown in the title block and passed through context
itemsRows to render (icon, title, optional value, click handler)
children (optional)BlocksOverride | ReactNode

Each item in items supports:

FieldTypeRequiredDescription
iconSvgIconComponentYesMUI icon component shown on the left of the row
titlestringYesPrimary row label
valuestringNoSecondary text shown under the title
onClick() => voidYesCalled when the row is clicked
Provide MUI icons

Pass icon components from @mui/icons-material (for example, PersonOutlined).

Code Examplesโ€‹

Live Editor
function Example() {
  const [lastEvent, setLastEvent] = React.useState('Ready');
  const items = [
    {
      icon: PersonOutlined,
      title: 'Username',
      value: 'johndoe',
      onClick: () => setLastEvent('Username clicked'),
    },
    {
      icon: EmailOutlined,
      title: 'Email',
      value: 'john.doe@example.com',
      onClick: () => setLastEvent('Email clicked'),
    },
    {
      icon: LockOutlined,
      title: 'Password',
      value: 'โ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ข',
      onClick: () => setLastEvent('Password clicked'),
    },
  ];

  return (
    <>
      <Settings settingsTitle="Account Settings" items={items} />
      <div style={{marginTop: 8, fontSize: 12, color: '#666'}}>{lastEvent}</div>
    </>
  );
}
Result
Loading...

Important Propsโ€‹

Core Propsโ€‹

PropTypeRequiredDefaultDescription
settingsTitlestringYes-Title for the settings section; used by Settings.Title when children is omitted
itemsSettingsItem[]Yes-Rows rendered by Settings.SettingsRows (see shape above)

Layout and Composition Propsโ€‹

PropTypeRequiredDefaultDescription
childrenBlocksOverride | ReactNodeNo-Compound sub-components or a block override function
classNamestringNo-Class name for the root container (also applies nbb-settings)
sxSxPropsNo-MUI system styles for the root Stack; its default includes panel padding and a #F3F3F3 background

Settings inherits StackProps (except children), so standard layout props are supported on the root. Default block order is title โ†’ settingsRows โ†’ settingsRow; the root filters settingsRow out of default rendering because it is a template row for overrides.

Sub-components read values from context and accept partial overrides:

  • Settings.Title โ€” Typography props; children defaults to settingsTitle from context (variant="h6", component="h4")
  • Settings.SettingsRows โ€” Stack props; optional items overrides context; children replaces auto-generated rows
  • Settings.SettingsRow โ€” Button props plus required icon (SvgIconComponent) and label; optional value and children for custom row content

Default UI Blocksโ€‹

BlockBuilt onNotes
Settings (root)StackSettings panel wrapper with responsive spacing, padding, and #F3F3F3 background
Settings.TitleTypographySection heading (variant="h6", component="h4")
Settings.SettingsRowsStackMaps items to Settings.SettingsRow instances
Settings.SettingsRowButton + Stack + Typography + ChevronRightOutlined row with icon, label, optional value, and trailing chevron

TypeScriptโ€‹

import { Settings } from '@nodeblocks/frontend-settings-block';
import type { SvgIconComponent } from '@mui/icons-material';

type SettingsItem = {
icon: SvgIconComponent;
title: string;
value?: string;
onClick: () => void;
};

function AccountSettingsPanel({rows}: {rows: SettingsItem[]}) {
return <Settings settingsTitle="Account Settings" items={rows} />;
}