@molecule/app-detail-header-angular
Feature · detail-header · App (browser) · v1.1.3 · Apache-2.0
Detail-page top bar with title, subtitle, status, actions, breadcrumb, optional search
npm install @molecule/app-detail-header-angularHow it works
@molecule/app-detail-header-angular is a ready-made detail-header 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 { DetailHeader } from '@molecule/app-detail-header-angular'
import { StatusBadge } from '@molecule/app-status-badge-angular'
@Component({
selector: 'app-order-header',
standalone: true,
imports: [DetailHeader, StatusBadge],
template: `
<header mol-detail-header title="Project Alpha" subtitle="Last updated 2 hours ago" sticky>
<app-status-badge slot="status" kind="success">Active</app-status-badge>
<button slot="actions" type="button" (click)="handleEdit()">Edit</button>
<span slot="meta">Owner: Alice</span>
</header>
`,
})
export class OrderHeader {
readonly handleEdit = (): void => {
console.log('edit project')
}
}Works with: @molecule/app-angular, @molecule/app-ui, @molecule/app-ui-angular
Reference
Angular detail-page header — the counterpart of
@molecule/app-detail-header-react: the same props and the same DOM for
the same input.
Exports <DetailHeader> — leading slot + title/subtitle + status +
right-aligned actions, with an optional meta row and an optional search
slot. Different from <PageHeader> (top of list/index pages) in
prioritising status + search + stickiness for long-scrolling detail
screens.
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 { DetailHeader } from '@molecule/app-detail-header-angular'
import { StatusBadge } from '@molecule/app-status-badge-angular'
@Component({
selector: 'app-order-header',
standalone: true,
imports: [DetailHeader, StatusBadge],
template: `
<header mol-detail-header title="Project Alpha" subtitle="Last updated 2 hours ago" sticky>
<app-status-badge slot="status" kind="success">Active</app-status-badge>
<button slot="actions" type="button" (click)="handleEdit()">Edit</button>
<span slot="meta">Owner: Alice</span>
</header>
`,
})
export class OrderHeader {
readonly handleEdit = (): void => {
console.log('edit project')
}
}
Type
feature
Installation
npm install @molecule/app-detail-header-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular
API
Interfaces
DetailHeaderProps
Props accepted by DetailHeader — the same props
@molecule/app-detail-header-react accepts. Node props (title,
subtitle, leading, status, actions, meta, search) are projected
content in Angular (an input cannot carry a node), so they are typed
unknown: pass node content as [slot=<name>] children of the host
element, and plain strings as the input.
interface DetailHeaderProps {
/** Primary heading — a string input, or `[slot=title]` projected content. */
title?: unknown
/** Optional subtitle shown below the title — a string input, or `[slot=subtitle]` content. */
subtitle?: unknown
/** Optional leading avatar / icon / logo, projected as `[slot=leading]` content. */
leading?: unknown
/** Optional status indicator, projected as `[slot=status]` content. */
status?: unknown
/** Right-aligned actions, projected as `[slot=actions]` content. */
actions?: unknown
/** Optional metadata row, projected as `[slot=meta]` content. */
meta?: unknown
/** Optional search slot, projected as `[slot=search]` content. */
search?: unknown
/** Whether to render with a sticky-top style (position: sticky). */
sticky?: boolean
/** Extra classes. */
className?: string
/** `data-mol-id` for AI-agent selectors. */
dataMolId?: string
}
Classes
DetailHeader
DetailHeader component.
Header row for a detail page — leading slot + title/subtitle + status +
actions, with optional meta row and search slot. The host IS the root
<header> (header[mol-detail-header]), matching React's root exactly.
The title, subtitle, leading, status, actions, meta and search content is
projected ([slot=<name>]); a string title or subtitle input renders
as text. Same props, same DOM as
@molecule/app-detail-header-react's DetailHeader.
The optional subtitle <p> and meta row stay in the template so their
<ng-content> capture points always mount, and leave the page while nothing
renders in them, as React's {subtitle && …} and {meta && …} render no
such element.
@Component({
selector: 'header[mol-detail-header]',
standalone: true,
imports: [],
inputs: ['title', 'subtitle', 'sticky', 'className', 'dataMolId'],
hostDirectives: [MolPlacement],
host: {
'[class]': 'classes()',
'[attr.data-mol-id]': 'dataMolId ?? null',
'[style]': 'stickyStyleText()',
},
// prettier-ignore
template: `<div [class]="cm().flex({ justify: 'between', align: 'center', gap: 'md', wrap: 'wrap' })"><div [class]="cm().flex({ align: 'center', gap: 'sm' })"><ng-content select="[slot=leading]" /><div [class]="cm().stack(1)"><div [class]="cm().flex({ align: 'center', gap: 'sm' })"><h1 [class]="cm().cn(cm().textSize('2xl'), cm().fontWeight('bold'))">@if (hasTitle) {<ng-container>{{ title }}</ng-container>}<ng-content select="[slot=title]" /></h1><ng-content select="[slot=status]" /></div><p #subtitleEl [class]="cm().textSize('sm')">@if (hasSubtitle) {<ng-container>{{ subtitle }}</ng-container>}<ng-content select="[slot=subtitle]" /></p></div></div><div [class]="cm().flex({ align: 'center', gap: 'sm' })"><ng-content select="[slot=search]" /><ng-content select="[slot=actions]" /></div></div><div #metaEl [class]="cm().flex({ align: 'center', gap: 'sm', wrap: 'wrap' })"><ng-content select="[slot=meta]" /></div>`,
})
export class DetailHeader {
/** Primary heading — a string input, or `[slot=title]` projected content. */
title?: unknown
/** Optional subtitle shown below the title — a string input, or `[slot=subtitle]` content. */
subtitle?: unknown
/** Whether to render with a sticky-top style (position: sticky). */
sticky?: boolean
/** Extra classes. */
className?: string
/** `data-mol-id` for AI-agent selectors. */
dataMolId?: string
/** The subtitle paragraph (always in the heading column; detached while it has nothing to render). */
@ViewChild('subtitleEl', { static: true }) private subtitleEl?: ElementRef<HTMLParagraphElement>
/** The meta row (always a root sibling; detached while it has nothing to render). */
@ViewChild('metaEl', { static: true }) private metaEl?: ElementRef<HTMLDivElement>
/**
* Keeps the optional subtitle and meta row on the page only while they
* render a text input or projected content, re-decided whenever either
* changes (a slot taken away and given back included).
*/
constructor() {
usePlacement((hasContent) => {
const subtitle = this.subtitleEl?.nativeElement
setElementPresent(subtitle, this.hasSubtitle || (subtitle ? hasContent(subtitle) : false))
const meta = this.metaEl?.nativeElement
setElementPresent(meta, meta ? hasContent(meta) : false)
})
}
/**
* The current class map.
* @returns The UIClassMap.
*/
cm(): UIClassMap {
return getClassMap()
}
/**
* Computes the header class list (React's `cm.cn(cm.stack(2), className)`).
* @returns The class string.
*/
classes(): string {
return this.cm().cn(this.cm().stack(2), this.className)
}
/**
* The header's inline style text (React's
* `style={sticky ? { position: 'sticky', top: 0, zIndex: 10 } : undefined}`);
* null when not sticky, so no `style` attribute renders.
* @returns The style text or null.
*/
stickyStyleText(): string | null {
return this.sticky ? styleText(STICKY_STYLE) : null
}
/**
* Whether a text title input renders (a projected title is not).
* @returns True when the title input renders as text.
*/
get hasTitle(): boolean {
return this.title !== undefined && this.title !== null
}
/**
* Whether a text subtitle input is present.
* @returns True when the subtitle input renders as text.
*/
get hasSubtitle(): boolean {
return this.subtitle !== undefined && this.subtitle !== null && this.subtitle !== ''
}
}
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 -
stickyappliesposition: sticky; top: 0but adds NO background — pass a surface class viaclassName(e.g. your ClassMap's surface helper) or content will scroll visibly through the header. -
There is no breadcrumb prop; put a breadcrumb in the
leadingslot or render one above the header (see@molecule/app-detail-page-layout-react, which has a breadcrumb slot). -
Node props are projected content:
title,subtitle,leading,status,actions,metaandsearchare selected by[slot=<name>]; plain strings may also be passed as inputs. -
Styling resolves through
getClassMap()— requires a wired ClassMap bond (standard molecule app setup). No text of its own, so no locale bond is needed; translate the values you pass in.