Multi-Column Layout

The <smart-multi-column-layout> component provides a three-column application shell — a left navigation <aside>, a main content region, and a right secondary <aside>, with an optional top header. It follows the Base + Standard + Wrapper pattern with an InjectionToken-based extension mechanism. The abstract MultiColumnLayoutBaseComponent defines the shared API — optional IMultiColumnLayoutOptions and cssClass (alias class). MultiColumnLayoutStandardComponent is a barebones placeholder concrete implementation. MultiColumnLayoutComponent is the public wrapper that renders MultiColumnLayoutStandardComponent by default and accepts a custom replacement via MULTI_COLUMN_LAYOUT_STANDARD_COMPONENT_TOKEN.


Usage

<smart-multi-column-layout [options]="options()">
  <h2>Quarterly report is ready</h2>
  <p>The Q3 numbers are in. Open the attachment for the full breakdown.</p>
</smart-multi-column-layout>

<ng-template #headerTpl>
  <strong>Inbox</strong>
</ng-template>

<ng-template #navTpl>
  <a href="#inbox">Inbox</a>
  <a href="#drafts">Drafts</a>
  <a href="#sent">Sent</a>
</ng-template>

<ng-template #secondaryTpl>
  <span>Storage: 4.2 GB of 15 GB used</span>
</ng-template>

The preview renders the code above in an application that registers every preset (provideSmartPresets(), see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.

Components

MultiColumnLayoutComponent (<smart-multi-column-layout>)

Main wrapper component. Renders MultiColumnLayoutStandardComponent by default. When MULTI_COLUMN_LAYOUT_STANDARD_COMPONENT_TOKEN is provided (or provideSmartPresets() registers the preset), renders the injected component via NgComponentOutlet, forwarding options and the class. Accepts main content via projected <ng-content>, which reaches the injected component's default <ng-content /> as well.

MultiColumnLayoutStandardComponent (<smart-multi-column-layout-standard>)

Barebones placeholder concrete implementation. Renders a wrapper <div> containing an optional <header> (when options.headerTpl is provided), an <aside class="nav">, a <main> element that projects <ng-content>, and an <aside class="secondary">. The external cssClass is applied to the wrapper. It does not include Tailwind UI styling — it exists solely as the default structural placeholder until a custom implementation is registered through the token.

MultiColumnLayoutBaseComponent (abstract)

Abstract base directive for extending custom multi-column-layout implementations. Exposes options as an InputSignal<IMultiColumnLayoutOptions | undefined> and cssClass as an InputSignal<string> (with alias class).

API

Inputs

InputTypeDefaultDescription
optionsInputSignal<IMultiColumnLayoutOptions | undefined>-Optional configuration (header, nav and secondary slots, title, widths)
classInputSignal<string>''External CSS classes (alias for cssClass)

IMultiColumnLayoutOptions

FieldTypeDefaultDescription
headerTplTemplateRef<unknown>-The header zone (<header>); wins over title in the preset.
navTplTemplateRef<unknown>-The navigation column (<aside class="nav">).
secondaryTplTemplateRef<unknown>-The secondary column (<aside class="secondary">), e.g. details or activity.
titlestring-Preset only: an <h1> in the header zone when headerTpl is not set.
width'full' | 'constrained''full'Preset only: constrained caps the main content container at max-w-7xl, centred.
secondaryWidth'sm' | 'md' | 'lg''sm'Preset only: the width of the secondary column (w-64, w-80, w-96).

The default MultiColumnLayoutStandardComponent consumes navTpl, secondaryTpl and headerTpl; title, width and secondaryWidth are read by MultiColumnLayoutPresetComponent (and are available to a custom implementation).

MULTI_COLUMN_LAYOUT_STANDARD_COMPONENT_TOKEN

InjectionToken from @smartsoft001/angular that allows replacing the default MultiColumnLayoutStandardComponent with a custom implementation. Provide a Type<MultiColumnLayoutBaseComponent> in your application or component providers; provideSmartPresets() provides MultiColumnLayoutPresetComponent for it together with every other preset.

Extending the base class

import { NgTemplateOutlet } from '@angular/common';
import {
  ChangeDetectionStrategy,
  Component,
  computed,
  TemplateRef,
  viewChild,
  ViewEncapsulation,
} from '@angular/core';

import {
  IMultiColumnLayoutOptions,
  MULTI_COLUMN_LAYOUT_STANDARD_COMPONENT_TOKEN,
  MultiColumnLayoutBaseComponent,
  MultiColumnLayoutComponent,
} from '@smartsoft001/angular';

/**
 * A custom multi column layout built on `MultiColumnLayoutBaseComponent`.
 *
 * The base contributes the `options` and `class` inputs; the implementation
 * decides the column order and where each `TemplateRef` slot of
 * `IMultiColumnLayoutOptions` is projected.
 */
@Component({
  selector: 'docs-custom-multi-column-layout',
  template: `
    <div [class]="containerClasses()">
      @if (options()?.title) {
        <h1 class="docs-multi-column-layout__title">{{ options()!.title }}</h1>
      }

      @if (options()?.headerTpl) {
        <header class="docs-multi-column-layout__header">
          <ng-container [ngTemplateOutlet]="options()!.headerTpl!" />
        </header>
      }

      @if (options()?.navTpl) {
        <aside class="docs-multi-column-layout__nav">
          <ng-container [ngTemplateOutlet]="options()!.navTpl!" />
        </aside>
      }

      <!-- The content of <smart-multi-column-layout> is projected here. -->
      <main class="docs-multi-column-layout__main">
        <ng-content />
      </main>

      @if (options()?.secondaryTpl) {
        <aside class="docs-multi-column-layout__secondary">
          <ng-container [ngTemplateOutlet]="options()!.secondaryTpl!" />
        </aside>
      }
    </div>
  `,
  imports: [NgTemplateOutlet],
  encapsulation: ViewEncapsulation.None,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CustomMultiColumnLayoutComponent extends MultiColumnLayoutBaseComponent {
  containerClasses = computed(() => {
    const classes = ['docs-multi-column-layout'];
    const width = this.options()?.width;
    if (width) classes.push(`docs-multi-column-layout--${width}`);
    const secondaryWidth = this.options()?.secondaryWidth;
    if (secondaryWidth) {
      classes.push(`docs-multi-column-layout--secondary-${secondaryWidth}`);
    }
    const extra = this.cssClass();
    if (extra) classes.push(extra);
    return classes.join(' ');
  });
}

/**
 * Registering the implementation against
 * `MULTI_COLUMN_LAYOUT_STANDARD_COMPONENT_TOKEN` makes every
 * `<smart-multi-column-layout>` in this injector render it instead of the
 * standard variation. The slots are `<ng-template>` references owned by this
 * host, because `IMultiColumnLayoutOptions` takes `TemplateRef`s.
 */
@Component({
  selector: 'docs-multi-column-layout-custom-example',
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [MultiColumnLayoutComponent],
  providers: [
    {
      provide: MULTI_COLUMN_LAYOUT_STANDARD_COMPONENT_TOKEN,
      useValue: CustomMultiColumnLayoutComponent,
    },
  ],
  template: `
    <smart-multi-column-layout [options]="options()">
      <p>Three unread conversations, oldest from Tuesday.</p>
    </smart-multi-column-layout>

    <ng-template #headerTpl>
      <span>Unread first</span>
    </ng-template>

    <ng-template #navTpl>
      <a href="#">Inbox</a>
      <a href="#">Drafts</a>
      <a href="#">Sent</a>
    </ng-template>

    <ng-template #secondaryTpl>
      <span>Storage: 4.2 GB of 15 GB used</span>
    </ng-template>
  `,
})
export class MultiColumnLayoutCustomExampleComponent {
  headerTpl = viewChild<TemplateRef<unknown>>('headerTpl');
  navTpl = viewChild<TemplateRef<unknown>>('navTpl');
  secondaryTpl = viewChild<TemplateRef<unknown>>('secondaryTpl');

  options = computed<IMultiColumnLayoutOptions>(() => ({
    title: 'Inbox',
    width: 'full',
    secondaryWidth: 'sm',
    headerTpl: this.headerTpl(),
    navTpl: this.navTpl(),
    secondaryTpl: this.secondaryTpl(),
  }));
}

Preset

MultiColumnLayoutPresetComponent (<smart-multi-column-layout-preset>) is a fully styled drop-in replacement for the barebones standard component. It extends MultiColumnLayoutStandardComponent and renders a Tailwind app-shell scaffold with explicit light/dark classes (every utility is smart:-prefixed).

Structure

  • root (data-role="root") — full-height gray page (smart:min-h-full smart:bg-gray-50 smart:dark:bg-gray-900); merges the external cssClass.
  • header (data-role="header") — rendered only when options.headerTpl or options.title is set. White surface with a bottom border, matching the stacked-layout/sidebar-layout preset headers. Renders headerTpl, falling back to a title <h1> (data-role="title").
  • flex row containing:
    • nav (data-role="nav", <aside>) — rendered only when options.navTpl is set. White surface, smart:w-64 smart:shrink-0 smart:border-e, mirroring the sidebar-layout preset nav.
    • content (data-role="content", <main>) — gray page surface with smart:py-8; projects <ng-content> inside an inner container whose horizontal rhythm follows options.width.
    • secondary (data-role="secondary", <aside>) — rendered only when options.secondaryTpl is set. White surface on the trailing edge (smart:border-s); width follows options.secondaryWidth.

Options consumed

The preset consumes the full IMultiColumnLayoutOptions surface (the standard component only reads the templates):

  • width — 'constrained' centers the main content container at max-w-7xl; 'full' (default) uses full width. Both keep px-4 sm:px-6 lg:px-8.
  • secondaryWidth — 'sm' → w-64 (default), 'md' → w-80, 'lg' → w-96.
  • headerTpl / title, navTpl, secondaryTpl — as above.

The class recipes are internal to the preset (not exported).

Token registration

Provide it for MULTI_COLUMN_LAYOUT_STANDARD_COMPONENT_TOKEN as above, or use provideSmartPresets(). The preset declares cssClass without the class alias: on the <smart-multi-column-layout-preset> selector bind [cssClass]; on <smart-multi-column-layout> pass class as usual.

Gaps

  • The nav and secondary asides render on the flex row at all viewport sizes — there is no built-in mobile collapse/drawer behavior.
  • Files: preset/preset.component.ts, preset/preset.component.html, preset/preset-classes.util.ts; story Preset in multi-column-layout.component.stories.ts.

Source

The component lives in packages/shared/angular/src/lib/components/multi-column-layout and is documented for Claude Code by the angular-components-multi-column-layout skill.

SmartMultiColumnLayout arranges a page in columns: an optional header (headerTpl, or title), a navigation column (navTpl), the main content (children) and a secondary column (secondaryTpl, e.g. details or activity). options.width makes the main region constrained or full width and options.secondaryWidth sizes the secondary column in the preset. The standard rendering is semantic markup (header, aside.nav, main, aside.secondary).


Usage

import {
  IMultiColumnLayoutOptions,
  SmartMultiColumnLayout,
} from '@smartsoft001/react';

const options: IMultiColumnLayoutOptions = {
  secondaryWidth: 'md',
  headerTpl: <strong>Inbox</strong>,
  navTpl: (
    <>
      <a href="#inbox">Inbox</a>
      <a href="#drafts">Drafts</a>
      <a href="#sent">Sent</a>
    </>
  ),
  secondaryTpl: <span>Storage: 4.2 GB of 15 GB used</span>,
};

export function MultiColumnLayoutUsageExample() {
  return (
    <SmartMultiColumnLayout options={options}>
      <h2>Quarterly report is ready</h2>
      <p>The Q3 numbers are in. Open the attachment for the full breakdown.</p>
    </SmartMultiColumnLayout>
  );
}

The preview renders the code above in an application that registers every preset (SMART_PRESET_COMPONENTS on SmartProvider, see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.

Exports

All from @smartsoft001/react.

ExportKindWhat it is
SmartMultiColumnLayoutcomponentRenders the implementation registered as components['multi-column-layout'] on SmartProvider, SmartMultiColumnLayoutStandard by default.
SmartMultiColumnLayoutPresetcomponentStyled multi-column-layout variation (preset).
SmartMultiColumnLayoutStandardcomponentThe default multi-column layout: an optional <header> (options.headerTpl), then <aside class="nav"> (options.navTpl), <main> with children and <aside class="secondary"> (options.secondaryTpl).

The preset's class helpers (getMultiColumnLayoutRootClasses, getMultiColumnLayoutHeaderClasses, getMultiColumnLayoutTitleClasses, getMultiColumnLayoutRowClasses, getMultiColumnLayoutNavClasses, getMultiColumnLayoutMainClasses, getMultiColumnLayoutContentContainerClasses, getMultiColumnLayoutSecondaryClasses) are exported too, for a custom implementation that wants the preset look.

Props and Types

SmartMultiColumnLayoutProps

PropTypeDefaultDescription
options?IMultiColumnLayoutOptions—The columns and their sizes.
className?string—Classes on the root element.
children?ReactNode—The main content.

IMultiColumnLayoutOptions

FieldTypeDefaultDescription
title?string—Heading in the header zone when headerTpl is not set (preset).
navTpl?ReactNode—The navigation column.
secondaryTpl?ReactNode—The secondary column.
headerTpl?ReactNode—The header zone.
width?SmartMultiColumnLayoutWidth—Preset: constrained caps the main container at max-w-7xl; full (default) spans the width.
secondaryWidth?SmartMultiColumnLayoutSecondaryWidth—Preset: width of the secondary column (sm by default).
  • SmartMultiColumnLayoutWidth: 'full' \| 'constrained'
  • SmartMultiColumnLayoutSecondaryWidth: 'sm' \| 'md' \| 'lg'

Replacing the Implementation

SmartMultiColumnLayout renders the component registered under the 'multi-column-layout' key of SmartProvider's components, and SmartMultiColumnLayoutStandard when nothing is registered there. Every SmartMultiColumnLayout below the provider then renders the registered component, which receives the same props.

SmartMultiColumnLayoutPreset is the styled (preset) implementation: register it under the 'multi-column-layout' key of SmartProvider's components, render it directly in place of SmartMultiColumnLayout, or spread SMART_PRESET_COMPONENTS on the provider to register every preset at once (see the react-provider skill). Pass components as a stable object (a module constant or a memoised value), or the context changes on every render.

import {
  IMultiColumnLayoutOptions,
  SmartMultiColumnLayout,
  SmartMultiColumnLayoutProps,
  SmartProvider,
} from '@smartsoft001/react';

/**
 * A custom multi-column layout: it receives the props of
 * `SmartMultiColumnLayout` (`options`, `className`, the main content as
 * `children`) and decides the column order and where each `ReactNode` slot of
 * `IMultiColumnLayoutOptions` goes.
 */
export function CustomMultiColumnLayout({
  options,
  className,
  children,
}: SmartMultiColumnLayoutProps) {
  const classes = [
    'docs-multi-column-layout',
    options?.width && `docs-multi-column-layout--${options.width}`,
    options?.secondaryWidth &&
      `docs-multi-column-layout--secondary-${options.secondaryWidth}`,
    className,
  ]
    .filter(Boolean)
    .join(' ');

  return (
    <div className={classes}>
      {options?.title && (
        <h1 className="docs-multi-column-layout__title">{options.title}</h1>
      )}

      {options?.headerTpl && (
        <header className="docs-multi-column-layout__header">
          {options.headerTpl}
        </header>
      )}

      {options?.navTpl && (
        <aside className="docs-multi-column-layout__nav">
          {options.navTpl}
        </aside>
      )}

      <main className="docs-multi-column-layout__main">{children}</main>

      {options?.secondaryTpl && (
        <aside className="docs-multi-column-layout__secondary">
          {options.secondaryTpl}
        </aside>
      )}
    </div>
  );
}

// A module constant: a new object on every render would change the context.
const components = { 'multi-column-layout': CustomMultiColumnLayout };

const options: IMultiColumnLayoutOptions = {
  title: 'Inbox',
  width: 'full',
  secondaryWidth: 'sm',
  headerTpl: <span>Unread first</span>,
  navTpl: (
    <>
      <a href="#">Inbox</a>
      <a href="#">Drafts</a>
      <a href="#">Sent</a>
    </>
  ),
  secondaryTpl: <span>Storage: 4.2 GB of 15 GB used</span>,
};

/**
 * Every `SmartMultiColumnLayout` below this provider renders
 * `CustomMultiColumnLayout` instead of the standard rendering.
 */
export function MultiColumnLayoutCustomExample() {
  return (
    <SmartProvider components={components}>
      <SmartMultiColumnLayout options={options}>
        <p>Three unread conversations, oldest from Tuesday.</p>
      </SmartMultiColumnLayout>
    </SmartProvider>
  );
}

Styling

  • The preset renders a full-height gray page, a white header zone, bordered side columns and a gray main region, with smart:dark: variants.
  • The standard rendering has no layout styles of its own.

Source

The component lives in packages/shared/react/src/lib/components/multi-column-layout and is documented for Claude Code by the react-components-multi-column-layout skill.