@molecule/app-detail-page-layout-angular
Feature · detail-page-layout · App (browser) · v1.1.3 · Apache-2.0
Two/three-column detail-page layout: breadcrumb + topbar + sidebar + main content
npm install @molecule/app-detail-page-layout-angularHow it works
@molecule/app-detail-page-layout-angular is a ready-made detail-page-layout feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { Component } from '@angular/core'
import { DetailPageLayout } from '@molecule/app-detail-page-layout-angular'
import { Breadcrumb } from '@molecule/app-breadcrumb-angular'
import { DetailHeader } from '@molecule/app-detail-header-angular'
interface Recipe {
title: string
relatedIds: string[]
}
@Component({
selector: 'recipe-page',
standalone: true,
imports: [DetailPageLayout, Breadcrumb, DetailHeader],
template: `
<div mol-detail-page-layout sidebarPosition="right" sidebarWidth="md" dataMolId="recipe-detail">
<app-breadcrumb slot="breadcrumb" [items]="crumbs" />
<app-detail-header slot="topBar" [title]="recipe.title" sticky />
<app-recipe-sections slot="main" [recipe]="recipe" />
<app-related-recipes slot="sidebar" [ids]="recipe.relatedIds" />
</div>
`,
})
export class RecipePage {
readonly crumbs = [
{ label: 'Recipes', href: '/recipes' },
{ label: 'Tomato soup', href: '/recipes/tomato-soup' },
]
readonly recipe: Recipe = { title: 'Tomato soup', relatedIds: ['r2', 'r3'] }
}Works with: @molecule/app-angular, @molecule/app-ui, @molecule/app-ui-angular
Reference
Angular detail-page layout scaffold.
Exports <DetailPageLayout> — breadcrumb + top bar + [main column +
optional sidebar]. All regions are projected slots. It is the Angular
counterpart of @molecule/app-detail-page-layout-react: same props and
the same DOM for the same input.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { Component } from '@angular/core'
import { DetailPageLayout } from '@molecule/app-detail-page-layout-angular'
import { Breadcrumb } from '@molecule/app-breadcrumb-angular'
import { DetailHeader } from '@molecule/app-detail-header-angular'
interface Recipe {
title: string
relatedIds: string[]
}
@Component({
selector: 'recipe-page',
standalone: true,
imports: [DetailPageLayout, Breadcrumb, DetailHeader],
template: `
<div mol-detail-page-layout sidebarPosition="right" sidebarWidth="md" dataMolId="recipe-detail">
<app-breadcrumb slot="breadcrumb" [items]="crumbs" />
<app-detail-header slot="topBar" [title]="recipe.title" sticky />
<app-recipe-sections slot="main" [recipe]="recipe" />
<app-related-recipes slot="sidebar" [ids]="recipe.relatedIds" />
</div>
`,
})
export class RecipePage {
readonly crumbs = [
{ label: 'Recipes', href: '/recipes' },
{ label: 'Tomato soup', href: '/recipes/tomato-soup' },
]
readonly recipe: Recipe = { title: 'Tomato soup', relatedIds: ['r2', 'r3'] }
}
Type
feature
Installation
npm install @molecule/app-detail-page-layout-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular
API
Interfaces
DetailPageLayoutProps
Props for DetailPageLayout — the same props
@molecule/app-detail-page-layout-react accepts. Node props (breadcrumb,
topBar, main, sidebar) are projected content in Angular (an input
cannot carry a node), so they are typed unknown: pass them in the host
template, not as values.
interface DetailPageLayoutProps {
/** Breadcrumb rendered above everything, projected as `[slot=breadcrumb]` content. */
breadcrumb?: unknown
/** Sticky top bar — title, status, actions, projected as `[slot=topBar]` content. */
topBar?: unknown
/** Main content column (usually stacked cards / sections), projected as `[slot=main]` content. */
main?: unknown
/** Optional sidebar column (related items, metadata cards), projected as `[slot=sidebar]` content. */
sidebar?: unknown
/** Sidebar position — `'right'` default or `'left'`. */
sidebarPosition?: 'left' | 'right'
/** Sidebar width preset. Defaults to `'md'`. */
sidebarWidth?: 'sm' | 'md' | 'lg'
/** Extra classes on the outer wrapper. */
className?: string
/** `data-mol-id` for AI-agent selectors. */
dataMolId?: string
}
Classes
DetailPageLayout
DetailPageLayout component.
Two- or three-row detail-page scaffold: breadcrumb (optional), top bar
(optional sticky), two-column body with a main region and an optional
sidebar on either side. The host IS the outer <div>
(div[mol-detail-page-layout]), matching React's root exactly. The layout
uses ClassMap tokens (cm.stack(4), cm.flex, cm.flex1) so the bonded
styling layer controls the visual treatment.
The four regions are projected content ([slot=breadcrumb],
[slot=topBar], [slot=main], [slot=sidebar]). React renders the
sidebar inside an <aside> that exists only when a sidebar is supplied and
sits before or after the main column per sidebarPosition. The template
holds one <aside> at each position — the projection slot must exist for
[slot=sidebar] content — and the projection is placed into whichever one
React would render, with neither left in the DOM when no sidebar content was
projected.
@Component({
selector: 'div[mol-detail-page-layout]',
standalone: true,
hostDirectives: [MolPlacement],
inputs: [
'breadcrumb',
'topBar',
'sidebar',
'sidebarPosition',
'sidebarWidth',
'className',
'dataMolId',
],
host: {
'[class]': 'classes()',
'[attr.data-mol-id]': 'dataMolId ?? null',
},
template: `<ng-content select="[slot=breadcrumb]"></ng-content
><ng-content select="[slot=topBar]"></ng-content>
<div #bodyEl [class]="bodyClasses()">
<aside #leftAside [style.flex-basis]="sidebarBasis()" [style.flex-shrink]="'0'">
<ng-content select="[slot=sidebar]"></ng-content>
</aside>
<main #mainEl [class]="mainClasses()">
<div [class]="stackClasses()"><ng-content select="[slot=main]"></ng-content></div>
</main>
<aside #rightAside [style.flex-basis]="sidebarBasis()" [style.flex-shrink]="'0'"></aside>
</div>`,
})
export class DetailPageLayout {
/** Breadcrumb rendered above everything (projected `[slot=breadcrumb]` content). */
breadcrumb?: unknown
/** Sticky top bar (projected `[slot=topBar]` content). */
topBar?: unknown
/** Optional sidebar column (projected `[slot=sidebar]` content). */
sidebar?: unknown
/** Sidebar position — `'right'` default or `'left'`. */
sidebarPosition?: 'left' | 'right'
/** Sidebar width preset. Defaults to `'md'`. */
sidebarWidth?: 'sm' | 'md' | 'lg'
/** Extra classes on the outer wrapper. */
className?: string
/** `data-mol-id` for AI-agent selectors. */
dataMolId?: string
/** The sidebar aside at React's left position (the projection capture point). */
@ViewChild('leftAside') leftAside?: ElementRef<HTMLElement>
/** The sidebar aside at React's right position. */
@ViewChild('rightAside') rightAside?: ElementRef<HTMLElement>
constructor() {
usePlacement((hasContent) => this.placeSidebar(hasContent))
}
/**
* The current class map.
* @returns The UIClassMap.
*/
cm(): UIClassMap {
return getClassMap()
}
/**
* Computes the wrapper class list.
* @returns The class string.
*/
classes(): string {
return this.cm().cn(this.cm().stack(4), this.className)
}
/**
* The body row's class (`cm.flex({ align, gap, direction })`).
* @returns The class string.
*/
bodyClasses(): string {
return this.cm().cn(
this.cm().flex({
align: 'start',
gap: 'lg',
direction: this.position() === 'left' ? 'row' : 'row',
}),
)
}
/**
* The main column's class (`cm.flex1`), through `cn()` so a token that is a
* function in the bonded map resolves to its string.
* @returns The class string.
*/
mainClasses(): string {
return this.cm().cn(this.cm().flex1)
}
/**
* The main column's inner stack class (`cm.stack(4)`).
* @returns The class string.
*/
stackClasses(): string {
return this.cm().stack(4)
}
/**
* The sidebar position (React's default parameter).
* @returns `'left'` or `'right'`.
*/
position(): 'left' | 'right' {
return this.sidebarPosition ?? 'right'
}
/**
* The sidebar's fixed flex-basis width from the preset (React's default
* parameter: an `undefined` binding must not erase the `'md'` default).
* @returns The CSS width.
*/
sidebarBasis(): string {
return `${SIDEBAR_WIDTH[this.sidebarWidth ?? 'md'] * 4}px`
}
/**
* Renders the sidebar aside where React would render it: the left aside
* holds the projected content when the sidebar sits before the main column,
* the right aside when it sits after it, and neither renders when no sidebar
* content was projected.
*
* @param hasContent - Reads whether a slot has content.
*/
private placeSidebar(hasContent: SlotReader): void {
const left = this.leftAside?.nativeElement
const right = this.rightAside?.nativeElement
if (!left || !right) return
const present = hasContent(left)
const onRight = present && this.position() === 'right'
if (onRight) placeContent(left, right)
else placeContent(left, null)
setElementPresent(left, present && !onRight)
setElementPresent(right, onRight)
}
}
Injection Notes
Requirements
Peer dependencies:
@angular/common^22.0.0@angular/core^22.0.0@angular/platform-browser^22.0.0@molecule/app-angular^3.13.0 || ^4.0.0@molecule/app-ui^1.0.1@molecule/app-ui-angular^1.1.0
Runtime Dependencies
-
@angular/common -
@angular/core -
@angular/platform-browser -
@molecule/app-angular -
@molecule/app-ui -
@molecule/app-ui-angular -
The layout itself does NOT make
topBarsticky — it just stacks the regions. Use a slot component that brings its own stickiness (e.g.<app-detail-header sticky>), or wrap your top bar in a sticky container. -
sidebarWidthpresets are fixed flex-basis widths: sm = 256px, md = 320px, lg = 384px. There is no built-in responsive collapse — hide the sidebar yourself on narrow viewports if needed. -
RecipeSectionsandRelatedRecipesabove are your own app components — any content works in the slots ([slot=breadcrumb],[slot=topBar],[slot=main],[slot=sidebar]). -
Styling resolves through
getClassMap()— requires a wired ClassMap bond (standard molecule app setup).