Container

Layout primitive that constrains/wraps page content. The <smart-container> wrapper renders ContainerStandardComponent by default (a neutral <div> that exposes data-mode / data-padding attributes for downstream styling). ContainerPresetComponent maps the options to real Tailwind layout utilities. Consumers can replace the standard with the preset or a custom variant via CONTAINER_STANDARD_COMPONENT_TOKEN.


Usage

<smart-container [options]="options">
  <h1>Account settings</h1>
  <p>Manage your profile, notifications and billing details.</p>
</smart-container>

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.

Public API

Wrapper: smart-container

InputTypeDefaultDescription
optionsIContainerOptionsundefinedLayout configuration
classstring''Extra CSS classes on the container <div> of the active implementation

IContainerOptions

FieldTypeDefaultDescription
mode'full-width' | 'constrained' | 'container'undefinedThe standard writes it to data-mode. In the preset: container centres at max-w-7xl, constrained at max-w-5xl, full-width (also when unset) spans the width.
padding'none' | 'mobile' | 'always'undefinedThe standard writes it to data-padding. In the preset: always pads at every breakpoint, mobile only below sm, none (also when unset) not at all.
narrowbooleanundefinedPreset only (the standard ignores it): tightens the width to max-w-3xl, centred, whatever the mode.

Content Projection

SelectorDescription
defaultBody content rendered inside the wrapper

Architecture

Three-layer pattern mirroring <smart-toggle>:

  1. ContainerBaseComponent (@Directive()) — shared inputs (options, cssClass with the class alias) and the smartType = 'container' discriminator. No outputs, no methods.
  2. ContainerStandardComponent (selector: smart-container-standard) — default concrete implementation extending the base. Renders a single <div> with [class], [attr.data-mode], [attr.data-padding], and <ng-content />.
  3. ContainerComponent (selector: smart-container) — wrapper. Uses inject(CONTAINER_STANDARD_COMPONENT_TOKEN, { optional: true }) + *ngComponentOutlet to render the injected component, falling back to <smart-container-standard>. It passes options and class to the injected component and captures the projected content once, so it reaches whichever renders: the standard component, or the injected component's default <ng-content />.

Overriding with Custom Implementation

A subclass of ContainerBaseComponent registered under CONTAINER_STANDARD_COMPONENT_TOKEN replaces the standard component in every <smart-container> of that injector. It reads options() and cssClass() (the wrapper's class) and renders the children in its default <ng-content />.

Content Projection

The wrapper uses *ngComponentOutlet to render any token-provided implementation and passes the children placed between <smart-container>...</smart-container> to it as outlet content, so they render in the injected component's default <ng-content /> slot.

Consequences for custom implementations:

  • The default ContainerStandardComponent receives the children through its <ng-content /> as before.
  • A custom component provided via CONTAINER_STANDARD_COMPONENT_TOKEN gets them in its first <ng-content /> (put the default slot first if it also has select slots).
  • The children arrive wrapped in one display: contents element. Layout (flex, grid, gap) is unaffected, but selectors on the slot's parent that target its direct children (space-y-*, divide-*, > *) do not reach them.

Preset

ContainerPresetComponent (selector smart-container-preset) is a styled drop-in for the neutral standard component. It extends ContainerStandardComponent and maps IContainerOptions to real Tailwind layout utilities (all smart:-prefixed) on a single root <div data-role="container"> that preserves <ng-content />. No new options fields are introduced.

Class mapping (computed by an internal helper of the preset, not exported):

OptionClasses
mode: 'container'smart:mx-auto smart:max-w-7xl
mode: 'constrained'smart:mx-auto smart:max-w-5xl
mode: 'full-width' / unsetsmart:w-full
narrow: truetightens max-width to smart:max-w-3xl (wins over the mode max-width, stays smart:mx-auto)
padding: 'always'smart:px-4 smart:sm:px-6 smart:lg:px-8
padding: 'mobile'smart:px-4 smart:sm:px-0
padding: 'none' / unsetno padding classes

The extra classes (class on the wrapper, or class / [cssClass] on <smart-container-preset> used directly) are appended after the mapped classes.

Register it through CONTAINER_STANDARD_COMPONENT_TOKEN to restyle every <smart-container>, or register every preset at once with provideSmartPresets().

Projected children render both through <smart-container> with the preset registered on the token and with <smart-container-preset> used directly (see "Content Projection" above). Story: container.component.stories.ts → Preset.

Source

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

SmartContainer wraps page content to control its width and horizontal padding. options.mode (full-width, constrained, container), options.padding (none, mobile, always) and options.narrow describe the layout. SmartContainerStandard (the default) is a neutral div that only exposes data-mode / data-padding; SmartContainerPreset maps the options to real Tailwind layout utilities.


Usage

import { IContainerOptions, SmartContainer } from '@smartsoft001/react';

const options: IContainerOptions = {
  mode: 'constrained',
  padding: 'mobile',
};

export function ContainerUsageExample() {
  return (
    <SmartContainer options={options}>
      <h1>Account settings</h1>
      <p>Manage your profile, notifications and billing details.</p>
    </SmartContainer>
  );
}

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
SmartContainercomponentRenders the implementation registered as components.container on SmartProvider, SmartContainerStandard by default.
SmartContainerPresetcomponentStyled container variation (preset).
SmartContainerStandardcomponentThe default container rendering: a neutral div exposing options.mode / options.padding as data-mode / data-padding for the application's own styling.

The preset's class helpers (getContainerClasses) are exported too, for a custom implementation that wants the preset look.

Props and Types

SmartContainerProps

PropTypeDefaultDescription
options?IContainerOptions—Width mode, padding and narrow flag.
className?string—Classes on the container div.
children?ReactNode—The content.

IContainerOptions

FieldTypeDefaultDescription
mode?'full-width' | 'constrained' | 'container'—The standard writes it to data-mode. In the preset: container centres at max-w-7xl, constrained at max-w-5xl, full-width (also when unset) spans the width.
padding?'none' | 'mobile' | 'always'—The standard writes it to data-padding. In the preset: always pads at every breakpoint (px-4 / sm:px-6 / lg:px-8), mobile only below sm, none not at all.
narrow?boolean—Preset only (the standard ignores it): centres at max-w-3xl, whatever the mode.

Replacing the Implementation

SmartContainer renders the component registered under the 'container' key of SmartProvider's components, and SmartContainerStandard when nothing is registered there. Every SmartContainer below the provider then renders the registered component, which receives the same props.

SmartContainerPreset is the styled (preset) implementation: register it under the 'container' key of SmartProvider's components, render it directly in place of SmartContainer, 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.

Styling

  • With the default SmartContainerStandard, style [data-mode] / [data-padding] yourself, or register SmartContainerPreset.
  • className is appended to the container.

Source

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